Questions about bash only, as opposed to other Bourne/POSIX shells. For all Bourne/POSIX-style shells, use the /shell tag instead.

learn more… | top users | synonyms

-1
votes
0answers
24 views

How can I make a Linux system output a bell sound when no packet is received before the next packet is transmitted with the ping command?

This is easy enough on OS X. I just use ping -A example.com and it works just fine. (Note the capital "A".) But it doesn't work like that on Linux. On Linux, the manual page reads as follows: ...
0
votes
1answer
8 views

How to create a module on a CentOS cluster

I would like to create a module on a CentOS 6 cluster (e.g. module load gcc-4.7.2). Are there any good tutorials illustrating this or could someone provide a "Hello World" type tutorial? I have ...
0
votes
0answers
25 views

shell script in doing operation for 2 folder tree [duplicate]

I have a directory looks like: dhcp-18-189-47-44:CE-06-new-stuctures_backup wenxuanhuang$ ls DFT-00001 DFT-00004 DFT-00007 DFT-00010 DFT-00013 DFT-00016 DFT-00019 DFT-00022 DFT-00025 DFT-00028 ...
1
vote
3answers
31 views

Read cells in csv file

I have this table of numbers saved in csv file format as follow: 5, 6, 9, 5, 2, 8, 1, 1, 1, 2, 3, 6, . . . . . . . . . . . . . . . . . . . . Every row in this table describe a ...
0
votes
1answer
20 views

extract subfolders outside and rename if necessary

I have a directory looks like: dhcp-18-189-47-44:CE-06-new-stuctures_backup wenxuanhuang$ ls DFT-00001 DFT-00004 DFT-00007 DFT-00010 DFT-00013 DFT-00016 DFT-00019 DFT-00022 DFT-00025 DFT-00028 ...
1
vote
1answer
37 views

Can't redirect cut output

When I try to redirect the output of cut it always seems to be empty. If don't redirect it, the output shows in terminal as expected. This is true for OS X 10.10 and Linux 4.1.6. This works: ...
5
votes
1answer
121 views

How to have type-ahead apply to bash history search (Ctrl-R)?

Context Typeahead in bash: good When a bash shell is busy (initializing, running a command), one can type before the next prompt appears. If the shell has launched a program, that program will ...
2
votes
3answers
31 views

Different 'time's called in similar environments in bash

I was told that people using bash will have to differentiate between the shell-builtin time and /usr/bin/time ( time(1) ). I had to time a program and also had to find ways to automate input, using ...
0
votes
1answer
34 views

Parsing a file to determine what values to use [duplicate]

I have a script and a "config" file that pull variables from. I created the configuration file called config.cfg and used it in my script as such: #! /bin/bash if [ -f ./config.cfg ] then ...
1
vote
4answers
85 views

Show ratio for all availiable resolutions

I tried to get the ratio with this script: echo "$(xrandr)"|cut -f 4 -d" "|sed 's/x/00 \\\* /g'|while read i; do echo "$i = "$(expr $i); done but I get errors like 102400 * 768 = expr: ...
0
votes
0answers
36 views

Passing variables through <<EOF [on hold]

fdisk /dev/$ROOTDISK <<PARTCMD d $ROOTPARTNUM n p $ROOTPARTNUM PARTCMD How can i pass the $ROOTPARTNUM variable?
0
votes
1answer
48 views

How can I merge 3 commands and execute them

I'm try to run a script that figures out the paths based on the hostname: e.g. if hostname returns computer1 I would like to run path/to/Computer1.py (where path/to is a path that will always be the ...
4
votes
1answer
28 views

How do I abort fc without executing the command?

The command fc will allow visual editing of the previous command. If I change my mind in the editor, how do I stop the command from being executed. In vim, typing q! or q both result in the command ...
0
votes
0answers
17 views

Environment Variable not Exporting [duplicate]

I have this script that I'm writing, basically as my own free dynamic dns system (with a bit more manual-ness at the moment). Here it is: #!/bin/bash ...
0
votes
1answer
22 views

sort process by cpu usage in cygwin

please help me to sort process by cpu usage in cygwin. I already tried tasklist but it shows only process by memory usage .
3
votes
2answers
42 views

process Count of each user in ps aux command

How can i create a script to count process run by each user in ps aux. I used this ps aux | awk '{print $1}' | grep root | wc -l but it lists count of root user only . I want to list number of ...
1
vote
1answer
27 views

Can I uncompress a zip file containing a disk image and then save that to an SD card all in one step?

I am under the following restrictions: I have a 1.0 GB .zip file on my computer which contains one file, a disk image of raspbian. When uncompressed, this file is 3.2 GB large and named ...
1
vote
0answers
21 views

Why does history not overwrite but append when histappend is set to off in Bash?

Several days ago, I had one Terminal tab doing ssh, and the other doing a lot of work locally. And then I restarted the machine (on a Mac with Mavericks). When I ran Terminal again, I found that all ...
17
votes
2answers
430 views

What does 'exec {fd}</dev/watchdog' do in Bash

That is literal, {fd} isnt a placeholder. I have a script that does this, and does not source in anything, nor does it reference {fd} anywhere else. Is this valid bash? exec {fd}</dev/watchdog
2
votes
5answers
280 views

Get very next word of a substring in a string

I need to get the next word of a word in a string. I tried to write a script but it's not working. And it's good if you suggest me any other alternatives to achieve this. Script: #!/bin/bash ...
1
vote
3answers
33 views

Select and sort IP address keeping the whole line

So I need to sort the IP Addresses and then sort my line by them. I can sort IP addres in a file by using : sort -n -t . -k1,1 -k2,2 -k 3,3 -k4,4 If my file looks like : add method1 a.b.c.d ...
0
votes
2answers
37 views

Different behaviour of eval “ command \”$@\“ ”, “$@”, and “$(echo $@)” when used as arguments [duplicate]

I would like to pass multiple arguments to the Tor browser (firefox) programatically through a function arbitrarily entitled tor. This is so as to command tor search terms and voila! My search terms. ...
-3
votes
1answer
42 views

How can i replace a specific string within a line inside a text file [duplicate]

$ cat text.txt my name is Steven my age is 10 i like dogs What command will be fitting so that echo "Kate" will replace Steven on text.txt?
13
votes
2answers
151 views

Fastest way to delete duplicates in large wordlist?

I need to deduplicate a large wordlist. I tried several commands and did some research here and here where they explain that the fastest way to deduplicate a wordlist seems to be using awk. awk ...
4
votes
4answers
342 views

$@ except the 1st argument

I need to write a shell script that runs in this way: ./myscript arg1 arg2_1 arg2_2 arg2_3 ....... arg2_# there is a for loop inside script for i in $@ However, as I know, $@ includes $1 up to ...
3
votes
1answer
79 views

weird characters in bash shell

Sometimes when I use the rm tool or stat tool in bash shell I get following weird characters: root@server:~# rm -vr blah removed directory: �blah� root@server:~# Locale settings can be seen here: ...
0
votes
2answers
33 views

Insert text to file using bash scripts (NOT appending)

I want to add text to a file using shell-scripts. The solution I know is if you want to insert your text into a newline (appending): echo "mytext" >> myfile.txt what I want to have a ...
2
votes
2answers
31 views

How can I send multiple options to one variable

I am running a loop for an array of variables that generates three more variables. i.e for foo in ${bar[@]}; do bar1=$(echo $foo | awk '{print$1}'); bar2=$(echo $foo | awk '{print$2}'); ...
2
votes
2answers
64 views

List transient files by numerical value having number greater than a given constantly varying filename

I've a directory having constantly changing filenames (by numerical value) listed as: -rw-rw----. 1 root root 10493952 May 7 10:39 A0000000.LOG -rw-rw----. 1 root root 10493952 May 7 08:38 ...
1
vote
1answer
25 views

Starting in normal mode on bash

I was very happy to discover that I could use vi keybindings in the bash shell (bash vi mode). I am a little frustrated now however that the shell always defaults to insert mode rather than normal ...
1
vote
5answers
111 views

lines to columns with awk

I have to following sample output: <HARDWARE> <NAME>WIN1</NAME> <OS>Windows 7</OS> <IP>1.2.3.4</IP> <DOMAIN>contoso.com</DOMAIN> ...
0
votes
1answer
35 views

How to add a folder to a remote hosts PATH using a shell script?

I'd like to automate the process of syncing a local ~/bin folder to a remote host, and adding that folder to my remote shell's path. I've got the syncing part done, but am not sure how to automate ...
0
votes
1answer
35 views

How to add new column, where the value is based on existing columns with awk

I have a file of multiple columns. I would like to make an additional column based on the values of 2 columns from this file. Example input: A B C D E F 1 2 T TACA A 3 2 3 4 I R 8 2 9 3 A C 9 3 ...
3
votes
1answer
149 views

Exit bash when find gets to a folder with permission denied

I'm trying to write my second Bash script. Where i go through folders recursively and make a list of and count files and folders. In a way it works but if "find" gets to a directory where it has ...
1
vote
1answer
18 views

adb pull not accepting a variable as source, gives *' does not exist..* error

I'm trying to use $EXTERNAL_STORAGE in the adb pull command. I noticed that the variable has its scope defined in Android only and so it would not work successfully in adb pull ...
3
votes
0answers
67 views

How to best track adventures of a novice administrator

I have this user that has limited sudo privileges, yet he manages to screw up from time to time. I would like to keep an eye on his adventures, so that I can reverse any damage with less digging. ...
0
votes
3answers
53 views

How to execute source command from sh file

I have file called install.sh and within this file I write something to $HOME/.bashrc file and after that I must call source command. In terminal I can type source $HOME/.bashrc but I can't do this in ...
1
vote
1answer
7 views

Outputting PID of Rails server(s) with ps aux | grep - breaks when put into an alias?

I'm trying to create an alias for an unwieldy command I'm using to output the PID and some other information about two rails servers I have running. When I simply run the command in terminal (over ...
1
vote
1answer
36 views

Identifying duplicate fields and print both with awk

I have a file with multiple columns and want to identify those where specific column values (cols 3-6) have been duplicated. The following code finds the duplicates but I want to display both ...
0
votes
2answers
37 views

How to store whole a paragraph as one element of array in bash script

I am using the following code to read data from a file abcd.txt and try to store in an array parameters, I am able to store 619617 in parameter[0] and update in parameters[1] but in parameters[2] I am ...
1
vote
0answers
38 views

Debian Jessie, copy file on NFS share (autofs) at shutdown

I'm on Jessie 8.1 so I use systemd to launch a service at shutdown. My service uses a script to copy a file on a NFS share (mounted by autofs). It doesn't work, I know the script can copy a file on ...
0
votes
2answers
29 views

Bash script error [closed]

I created this bash script based on answers I found here: If [[ $(autorep -J jobname | cut -c108-110 | sed -n '/ST/!'p | sed '/^$/d' | sed -n '/_/!'p) == *ST* ]]; then echo "Status is Started" fi ...
1
vote
2answers
64 views

Cron only occasionally sends e-mail on output and errors

On Debian 8.1, I'm using a Bash feature to detect whether the stackoverflow.com website is reachable: (echo >/dev/tcp/stackoverflow.com/80) &>/dev/null || echo "stackoverflow unreachable" This is ...
1
vote
1answer
27 views

How to suppress exit code of finished background jobs

Is there a way to hide the exit code of the background jobs that have finished? For example, if I run: sleep 5& After the 5s, if I hit return the terminal gives me: [1]+ Done ...
0
votes
2answers
55 views

sed in while read loop doesn't complete commands

I have a test file called testPage with the following text: || '''Title1''' || '''Title2''' || '''Title3''' || || Cell11 || Cell12 || Cell13 || || Cell21 || Cell22 || || Cell31 || Cell32 || || Cell41 ...
0
votes
1answer
25 views

Display Spinner while waiting for some process to finish

How can I show spinner till command line finish it is job? In other words, If I am running a script and I want to show spinner while this script is running and the spinner disappears when the script ...
0
votes
1answer
29 views

DNS Query Script

I am trying to get all the A records for some domains. The best way I have found is to use https://www.whatsmydns.net and the nexcess tool. The issue is that it is very slow to copy paste them and ...
0
votes
0answers
7 views

Zenity, how to manage cryptsetup prompt?

With Zenity, I display a progressBar and install/config many stuff on a Linux Mint (Debian) computer. I had to avoid any prompt. But one step prompts Enter a passphrase:, this is cryptsetup ...
0
votes
0answers
12 views

Zenity. How to run as an application?

I built a script (bash), then I overlaid it with Zenity (to have a progressbar in a GUI for non linuxian users). How can I deliver it as an app, not a .sh ? And never show a square of terminal ?
0
votes
1answer
4 views

Find line within file matching pattern and make a substitution

I'm trying to simplify my life here but I'm stuck. I have a file containing multiple lines. Each line has a user and a number. I'd like to know a bash one-liner to search for a user and change the ...