Questions specific to GNU’s Bourne Again SHell, as opposed to other Bourne/POSIX shells. For questions about Unix shells in general, use the /shell tag instead.

learn more… | top users | synonyms

0
votes
1answer
20 views

How can I convert all the html files I get into text files after a wget command?

How can I convert all the html files I get into plain text files after a wget command? I'm thinking of using lynx to convert html files into ".txt" files, getting rid of tags. I have this snippet ...
0
votes
1answer
26 views

practice linux for practical use [on hold]

I have learned and studied linux for 6 months with books like 'The linux commandline'. But, I'm just student, not a business man. When I study linux and do not use it for long time, I always forget ...
1
vote
3answers
43 views

Using grep in conditional statement in bash

I'm still very new to scripting in bash, and just trying a few what I thought would be basic things. I want to run DDNS that updates from the my server running Ubuntu 14.04. Borrowing some code from ...
1
vote
1answer
27 views

Awk field printing within the ternary operator

If you're familiar with DISA STIGs, the test for RHEL-06-000518 is /bin/rpm -Va 2>/dev/null \ | /bin/grep '^.M' What I want to do is pull just the file name out of that test, and make pretty ...
0
votes
1answer
40 views

`ssh` fails to reach destination

I am trying to ssh to another machine in my lab using the IP address. The IP address is 137.84.4.211 and let's say the host name is MyName. My IP address is 137.82.81.10. I don't know if this mean two ...
0
votes
0answers
16 views

How to generate following output file by using PBS script language?

I need to run interacting job with such specifications by using PBS on the cluster. This job must write the output file, in which there is following information (I have not specify this in the .pbs ...
-2
votes
0answers
25 views

how i can Download with wget? [on hold]

am trying to Download all of the files in website and every link inside it , with sudo wget -m https://someurl.com i need when it gets to the other link create a directory for it before ...
1
vote
1answer
20 views

How to express floating point expressions in bash scripts

Why does a2=100. echo 1.1*$a2|bc work on the terminal, but the 3 variants in the following script don't: a2=100. echo " 1.1*$a2|bc $(1.1*$a2|bc) $((1.1*$a2|bc)) ">x.sh
2
votes
2answers
46 views

find and replace double bracket values

I have a requirement to replace the [[KEY]] in double brackets in one of the html file with VALUE. Key values are available in different files. After replacement, I need to put output in separate ...
0
votes
1answer
18 views

Determining Domain Base Name from Nslookup Results [on hold]

I am trying to search all IP addresses that connected to my server and want to find abusive servers from nslookup results. nslookup 31.204.150.10 | grep "in-addr" Some example results: ...
-1
votes
3answers
33 views

In a bash shell script , how to write a loop that goes trough three values [duplicate]

I'm trying to write a shell script using bash for the following problem: Write a loop to go through three values (A B C) and displays each of these values to the screen (hint use a ‘for’ loop). ...
18
votes
3answers
1k views

Is there any way to execute commands from history?

For example: [root@ip-10-0-7-125 ~]# history | grep free 594 free -m 634 free -m | xargs | awk '{print "free/total memory" $17 " / " $ 8}' 635 free -m 636 free -m | xargs | awk '{print ...
1
vote
1answer
28 views

Meaning of the bash shortcut Alt+{

What's the meaning of the output from the Bash shortcut Esc { (Esc, Shift+[ on a US keyboard)? e.g., $ ls brown.txt file1.txt file2.txt fox.txt quick.txt Esc { produces the following at the ...
1
vote
1answer
26 views

Remove certain types of files except in a folder

I have a command in my makefile for clean: rm -rf */*.o */*.cmo */*.cmi */*.cmx */*.cma */*.cmxa */*.annot Now I would like to write a cleanpartial that removes these files except those in the ...
0
votes
2answers
35 views

Saving Output In a Variable and Re-using it

page=`grep $x /var/www/vhosts/example.com/statistics/logs/access_log | awk '{print $7}'| sort |uniq -c |sort -nr` times=`$page | wc -l` I am trying to save output of grep in a variable as page. But ...
1
vote
2answers
67 views

Why is this script looping on the first line of the txt file

#!/bin/bash usernameFile="/home/netadmin/username_list.txt" logFile="/var/log/netvpn-mag-archive/netvpn-mag-20160" while read -r line < $usernameFile; do if [[ "$line" != " " ]]; then ...
0
votes
1answer
33 views

Conditions sent over ssh are performed locally, not remotely [duplicate]

So I am trying to do something like this: ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i \ /home/backupboy/.ssh/id_rsa [email protected] \ "[[ $(ls -1 /mnt/dir | wc -l) -gt 4 ...
0
votes
3answers
27 views

Accessing Secondary Variables

for x in `cat /var/www/vhosts/example.com/statistics/logs/access_log.processed | awk '{print $1}' | sort | uniq -c | sort -nr | awk {'if ($1 > 2000) print $2'}`; do #Works printf ...
2
votes
1answer
18 views

Connect via telnet and doing certain operations

I'm trying to code a script where I can connect via telnet to another server and execute certain operations, but I'm having problems with the result of this process. The objective is to connect to a ...
1
vote
0answers
42 views

bash script autobeautifiying using declare -f

I am trying to "beautify" scripts automatically by using declare -f function In a nutshell: Given a bash script foo , you can apparently "automagically" indent it by doing, in bash: MAGIC () { ...
0
votes
1answer
41 views

How to run a command on remote host from a service?

I have a service in '/etc/init.d'. In that service, I run a command on a remote machine using ssh as a user. Currently I do this in the following way: sudo -u user bash -c "ssh [email protected] ...
0
votes
2answers
36 views

Systemd bash builtins

I have an application that needs to use the commando source for setting his environment file. [Unit] Description=Programname After=syslog.target network.target [Service] User=root ...
3
votes
1answer
31 views

Why does path-completion in bash not always work?

With different bash-environments (different installations) I have different behaviors in terms of path-completion when hitting TAB on the command line after . Where is this handled? One specific ...
1
vote
1answer
21 views

Substitute with `…` multiline output of find command [duplicate]

I need to substitute output of find command to another command to process every found file, e.g.: mdls `find ~/target_dir/ -iname '*some*' -depth 1` (mdls is a command in OS X which get metadata ...
3
votes
1answer
41 views

Is there a way to use regex expressions to auto-fill filenames in bash?

Assuming I have a directory with files as shown: $ ls file0001.txt file0002.txt file0003.txt file0004.txt file0005.txt someotherfile.txt Lets say I want to run the following command: $ cat ...
2
votes
3answers
46 views

bash -c variable resolution in subshell

How do I resolve a variable in a subshell inside of "bash -c"? In the following, the second subshell -- the one with an "echo" inside -- resolves correctly. The first subshell -- with "touch" -- ...
0
votes
1answer
37 views

How to append tail command's outputs in a new line into a file with bash [on hold]

I'm trying to append the output of the tail command into a file, but this command runs in a for loop, and I want each output in a new line. My code is something like this: for file .... do ...
1
vote
0answers
37 views

Command that works fine typed into terminal does not work as a bash function [duplicate]

I have a function which is meant to keep a record of every program I've installed (really, I'm interested in keeping track of dependencies). I've tested out my command in a terminal and it works just ...
0
votes
1answer
33 views

loop port variable to connect to multiple computers

I have a few raspberry pi's creating reverse ssh tunnels on an ssh server. From that server I can connect on all the raspberry pi's. I want to create a bash script that will run on this ssh server, ...
1
vote
3answers
25 views

Rename only one file in each directory, based on condition

I have 100 folders inside every folder I have one or two files named as the following: XXX_001_014_max.jpg XXX_001_024_max.jpg I saved the folders names in a file "list.txt" I ran the following ...
0
votes
0answers
24 views

Custom interrupt handler for bash scripts [duplicate]

I'm writing a script that needs to keep track of all backgrounded processes it launches: index=0 for i in `ls $TOPOLOGY_FILE_PREFIX*` do if [ ! -z "$11" ]; then ./noc_sim.sh ...
0
votes
2answers
33 views

Flow control using Unix shell

I need to do an exercise at the university, its all about reading 3 values and identify if there is any duplicated value, which value is the greatest and which one is the least, the idea is if you ...
1
vote
0answers
14 views

How to have full completion in a run application dialog?

I've configured XFCE to execute gmrun as run dialog (Alt-F2). It works great with completion on commands but does not propose completion on arguments. How to set up a run dialog with full bash/zsh ...
0
votes
1answer
13 views

pass string to socat inside a script

I'm trying to create a script that fires a connection string at an application, so I can record the result. e.g. can I successfully connect and login to my application. From the commandline I can ...
1
vote
1answer
40 views

Bash reading from /dev/tcp, without external binaries

I'm trying to read files with bash tcp socket, So on one host I do, nc -l 8888 < /etc/passwd And on another machine, echo </dev/tcp/127.0.0.1/8888 But it didn't read the file as expected, ...
1
vote
1answer
72 views

BASH- Find owner of a file

Im looking for a way inside a bash script to return the owner of a file. I'm guessing that this is possible using "gawk" but I've honestly got no clue and there doesn't seem to be a comprehensible ...
0
votes
1answer
49 views

Plotting graphs using bash

I have a file in the following format: 1043481872 1043481872 1043481872 1043481872 1043481873 1043481873 1043481873 1043481873 1043481874 1043481874 1043481874 1043481875 My question now boils down ...
0
votes
0answers
22 views

Using bash to plot a graph [duplicate]

I have a huge file which contains BGP updates in the following fashion : BGP4MP|1043481872|A|64.200.199.3|7911|217.72.176.0/20|7911 8272 16102 16102 16102|IGP|64.200.199.3|0|0|7911:999 ...
-1
votes
1answer
23 views

All Aliases Stopped working suddenly (Linux Ubuntu 14.04.4 LTS) [on hold]

I have been using my system with Ubuntu for almost a year now. I have been using a .bashrc file throughout this time. I have build it according to my needs. Suddenly it stopped working and none of ...
0
votes
0answers
19 views

rsync and scp hang inside the bash script but run at the command line

I'm trying to execute scp and rsync commands inside of a bash script. The following happens when I run the bash script: scp -o StrictHostKeyChecking=no /tmp/foo '[email protected]:/tmp/foo' ...
2
votes
2answers
58 views

How can I remove a command from bash completion?

For bash completion, I would like to replace youtube-dl with youtubedl. I can make an alias for youtubedl, however, both youtube-dl with youtubedl will exist. Primarily, I just want to remove ...
5
votes
1answer
41 views

Performing atomic write operations in a file in bash

After going through the bash documentation, this question and this one it's still not clear to me how can I perform atomic write (append) operations to a file in bash. I have a script that is run in ...
2
votes
3answers
37 views

All files in a directory that do not end in a specific string?

I want to find all text files in a directory that do not end with the string: hello world How can I do this?
0
votes
3answers
24 views

How to filter log file for string inside single quotes?

I have a log file, which outputs information this way: 2016-01-01: foo bar fnord 2016-01-01: this is static 'this is of interest' some blob bar 2016-01-01: this is static 'this is of interest' some ...
0
votes
0answers
20 views

Is there a way to get partition information of a disk with sysfs?

my first question here - so please, don't be too hard with me... As the title says: I am wondering if there is a way to get partition information of a disk with sysfs. I know about some different ...
-2
votes
3answers
40 views

Simple way to make test file in bash

Working with file reading instruments I regularly need some text file to test a code. I would like to make such file quickly. I guess it would be great to produce the file with some bash one-liner. ...
-3
votes
0answers
30 views

Vncpasswd script for ubuntu 14 server

I have all other issues resolved one last thing is ,i want vncpasswd as automated . These commands are working perfectly when i copy paste them in terminal but these aint working in script File. I ...
0
votes
0answers
21 views

Emptying a log file getting updated with 2>&1 output redirection [duplicate]

I have a server which constantly writes outputs and errors to stdout and stderr. The command line I use for running my server is: Server options-list > log.txt 2>&1 & Now the problem ...
0
votes
0answers
8 views

how do you make a list/file for pacman to install from

I am trying to move from one arch install a (partitioned one) to another (a less-partitioned one) on my computer and I want a similar set up. So I was wondering if there was a simple way to get pacman ...
2
votes
0answers
40 views

put string to commandline

I am making a bashfunction that show a menu binded to pgdown to browse through a a window which list my history (like 4dos/4nt etcetera). I have made so one line is always highlighted. $pos is ...