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

8
votes
5answers
444 views

Why does [A-Z] match lowercase letters in bash?

In all shells I am aware of, rm [A-Z]* removes all files that start with an uppercase letter, but with bash this removes all files that start with a letter. As this problem exists on Linux and ...
0
votes
1answer
32 views

What means echo“{@@##}”?

We got a script that we need to understand, and at some point, we got this syntax: if [ "$PASS_CHAINE" = "TRUE" ] then echo "Launching DEGAGEMENT" | SLog cd $INTERFACE_D/bin_cm/deg ...
1
vote
1answer
20 views

OSX: Delete all matching certificates by command-line

Using shell script to delete all matching certificates. I found a list of certificates using: security find-certificate -c "certificatename" -a -Z|grep SHA-1|awk '{ print $NF }' Output is like ...
4
votes
2answers
41 views

tell if last command was empty in PROMPT_COMMAND

In bash, from inside PROMPT_COMMAND, is there a way to tell if the user just hit 'return' and didn't enter a command?
-2
votes
1answer
28 views

Restrict bash command for specific user [on hold]

I just searched on this page, but the answer does not meet my idea. My idea is when user called Bob access ssh and run a command, for example sudo apt-get update, then the bash sheell will respond ...
0
votes
1answer
21 views

Queue up multiple videos from Bash Script

-Skip to bold to skip the fluff - I'm new to ubuntu, so still learning the ropes of how bash scripting goes. I've got this code I've been working on, which works great. (side question - can I ...
3
votes
1answer
29 views

chkconfig does not support my script

I have looked and looked and none of the threads I have found are helping. We have a tomcat startup script that we modified slightly for our needs. It works fine on Centos / redhat 6 boxes, but does ...
1
vote
1answer
32 views

Provide three argument to one option using getopts in bash

I am trying to process a command line using getopts in bash. I have to pass three arguments after -w option. For example, -w 1 do loop. It should print one line before and after each line from loop ...
-1
votes
0answers
25 views

how to move directories by date to cooresponding monthly directoires

using bash, how would one move directories with a common name, by create date to a monthly corresponding directory without calling out the source specific create date? #!/usr/bin/bash $SourceDir ...
0
votes
1answer
65 views

Why is sed coming back with “unterminated `s' command”?

So I have a Bash script which looks like this: #!/bin/bash extentemplate=" exten => `$prevchannel`,n,Queue(`$prevchannelname`)\ exten => `$prevchannel`,n,Hangup()\ \ ;`$channelname`\ exten ...
8
votes
4answers
636 views

bash loop with 0.02 increment

I want to make a for loop in bash with 0.02 as increments I tried for ((i=4.00;i<5.42;i+=0.02)) do commands done but it didn't work. I appreciate if you help me out.
1
vote
0answers
40 views

Why does this pipe not end when the las process dies (zombie)?

I have a script run and monitored by svscan/supervise. When the last luces-hf/run: #!/bin/bash set -v export http_proxy=[redacted] curl -N -s https://[redacted] |\ grep --line-buffered "event" | ...
-1
votes
0answers
38 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
14 views

How to create a module on a CentOS cluster [on hold]

I would like to create a module on a CentOS 6 cluster (e.g. module load gcc-4.7.2). Basically, I have no clue how modules work. Are there any good tutorials illustrating this or could someone ...
0
votes
0answers
27 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
34 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
25 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
42 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
130 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
33 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
37 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
93 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
37 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
55 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
29 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
24 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
43 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 ...
19
votes
3answers
475 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
286 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
35 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
206 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 ...
5
votes
4answers
348 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
81 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
34 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
3answers
81 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
112 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
36 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
37 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
152 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
19 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
69 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
55 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
8 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 ...