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
vote
2answers
117 views

sed: problem while replacing string using wildcard

I am trying to replace a string using the following command: sed -e "s/\<$5\>/$6/g" "$2/$1" > "$4/$3" $5-> "hostname=*" $6-> "hostname=int1" $2/$1-> "source file path" $4/$3-> ...
0
votes
1answer
26 views

Ping: Result shows 56(84) instead of what is expected

I'm trying to modify a script to show lost packets as well as ping results. I'm only including the section that isn't working as some of the commands in the script are company specific. for myHost ...
1
vote
1answer
36 views

Cygwin, bash, change an environmental variable?

I have set up a Cygwin environment on my machine (Windows 8.1). pol@pol-lap1 ~/Downloads/software/database/firebird/Firebird-2.5.4.26856-0 $ `set | grep unknown` BASH_VERSINFO=([0]="4" [1]="3" ...
0
votes
0answers
71 views

SCP won't copy files due to output in .bashrc

I just uploaded my linux (mint to v. 17.1), and now I cannot upload files to a cluster via scp anymore. I understand that .bashrc cannot output anything during the process for it confuses scp, so when ...
0
votes
1answer
52 views

binary not in PATH variable - how to execute it?

There is a binary in my home directory: "foo" My PATH variable doesn't contains my home dir. I cannot change my PATH varible, since it's read-only Question: How can I execute this binary without ...
0
votes
2answers
47 views

Bash Script: Parsing a Folder of Text Files Daily without Duplicating Output

HylaFax keeps a history of faxes sent for about a week in its spool folder. I have a script that can go through the files, extract the user and page counts and output it to a log. What's the most ...
0
votes
2answers
75 views

bash - change filename in a loop

So I have my input directory, output directory and list of files: #!/bin/bash ## shell type dir_in=('/Users/dossa013/data/inland-data/input/') dir_out=('/Volumes/Macintosh HD 2/data/cmip5/cru/') ...
-1
votes
1answer
45 views

How to Interactively ask a user to change Permissions for a Specified File

I need to create a script that will allow a specified file to have its permissions changed interactively by asking the user if they would like to enable Read, Write and/or Execute one by one for each ...
1
vote
2answers
57 views

Pipe to my own script

I've recently noticed this message from grep "grep: warning: GREP_OPTIONS is deprecated; please use an alias or script" I receive this warning because --color=always is defined in my .bashrc file. ...
0
votes
3answers
45 views

Read line from file and add that to the same line of another file

I have one file like this: aaa bbbb c And another one like this: 1 1241 2 301094209 3 432423 I want this: 1 1241 aaa 2 301094209 bbbb 3 432423 c so I can plot it with Gnuplot. If you ...
0
votes
1answer
33 views

Iterating over an array in a shell script

I want to write code that reads a list of packages from an array and tells me whether the corresponding RPM is installed: ARRAY=( pkg-config python python-devel python-libs readline renderproto ...
-1
votes
1answer
37 views

Loop is not working as it should [closed]

Am i missing something, because this loop sometimes is not working as it should? #!/bin/bash Data="/path/to/data.txt" while true do if [ -f "$Data" ]; then rows=$(tail -n +1 "$Data" | wc ...
0
votes
1answer
30 views

FFMPEG batch convert quits before processing all files

I have an audiobook which consists of over 700 ra files (RealAudio) which I'm trying to batch convert to mp3 using ffmpeg. RA files are named as chapter-verse.ra (e.g. 13-01.ra) I run a script and it ...
2
votes
1answer
33 views

Scripteable GPT partitions using parted

I am partitioning eMMC using following commands in the script, parted /dev/mmcblk0 --script mklabel gpt parted /dev/mmcblk0 --script mkpart primary ext4 32MB 132MB parted /dev/mmcblk0 --script mkpart ...
0
votes
1answer
92 views

How to prevent expansion

My script parameters on the mask and consist parameters for the find tool: $mopt=false case $1 in ... -m|--mask-file) if $mopt; then or="-o" fi ...
2
votes
1answer
106 views

how to deal with arguments when executing a script

how to deal with arguments when executing a script my code is: #!/bin/bash DIR="$1" if [ DIR eq $1 ] then echo -n "total directories:" ; find $DIR -type d | wc -l echo -n "total files:" ; ...
-10
votes
1answer
54 views

What does the output of ls -l mean? [duplicate]

I'm wondering, what this particular entry of the output of ls -l means. Could someone please explain the meaning of the fields? -rwxr-xr-x 1 root root 920788 Mar 28 2013 bash
0
votes
3answers
43 views

Loop for snmpwalk in bash

I have an issue in my output using snmpwalk so i'm trying in this script: var=`snmpwalk -v2c -c private ${ip} .1.1.1.6` echo "${hostname}=>${var}" to have this output: R1=>Gauge32: 240 ...
0
votes
1answer
16 views

Getting the starting position in the history that will be appended to the history file (not read from the file or previously written)

I'm trying to write functions to remove some history lines using history -d before it is written to the file, while leaving them usable in the shell itself. But apparently this command will not ...
0
votes
1answer
58 views

Strange output when echoing variable from a different user

$ sudo su - user1 -c 'echo $DOMAIN_HOME' /app/user1/DOMAINHOME This looks fine, right? However, let's dig a little deeper: $ sudo su - user1 -c 'echo $DOMAIN_HOME' | tee test.out $less test.out ...
1
vote
2answers
67 views

Spawn multiple processes with a single command

Is there a way to create say 10 instances of a process (for example yes) with a single command? $instantiate 10 yes
0
votes
2answers
35 views

Getting error with sleep and argument in sh script [closed]

I'm doing something like this #!/bin/bash END=3 time_w = 1 for ((i=1;i<=END;i++)); do # do something sleep time_w done but I'm getting sleep: invalid time interval ‘time_w’
0
votes
2answers
47 views

How can I break out of a while loop, from within a nested case statement? [closed]

In the script below - which prompts the user to confirm that they want to proceed with running a potentially bad script - when the user enters Y at the prompt - it will break out of the case block, ...
1
vote
3answers
66 views

Difference between sh -x and ./ for script execution

So I have a simple shell script. What is the difference between the two commands in execution? Is there a preferred way? $sh -x foobar.sh OR $ ./foobar.sh I found the script executed slower when ...
0
votes
1answer
36 views

How to ignore spaces in file path for bash select statement [duplicate]

I have the following Bash Script: #!/bin/bash cd ~/Library/Developer/CoreSimulator/Devices/; files=$(find . -name iaGambro_gambro.sql) select file in $files; do if [ -n "$files" ]; then ...
1
vote
2answers
115 views

How to find maximum and minimum file size along with their path in a directory

I want to find out the maximum, minimum and average file size along with their path. Incase a directory holds similar file sile (say 15kb,15kb) it should display the path of both files and its files ...
1
vote
2answers
92 views

how to run script with a clean login shell

I am connected to remote machine Linux RH6 directly via ssh (key imported on server), when I execute a shell script with arguments for restarting the java service, I have a strange issue with ulimit: ...
0
votes
2answers
73 views

No of files and directories in a particular directory in shell script

I am working on Linux and it's new to me. I created a shell script countfiledirs. I want to know the number of files and directories in a particular directory. My code is: #!/bin/bash echo "total ...
5
votes
2answers
177 views

Bash displays international characters as escape sequences

When I press certain keys (e.g. German umlauts) in the bash command line, I get escape sequences. For example, ß gives me \303. These escape sequences are treated as single characters, so one ...
4
votes
0answers
29 views

Search history from multiple bash session only when Ctrl + R is used, not when arrow keys are used

I usually have multiple bash sessions open. I want the history from multiple session to appear when doing a search (with Ctrl + R). When arrow keys are used only the current bash session's history ...
0
votes
1answer
22 views

How can I match and substitute this multiline pattern in a bash script?

I have a file jail.local and it has sections like this [apache] enabled = true logpath = /var/log/apache/error.log [ssh] enabled = false port = ssh I want to match on the string [ssh] and ...
2
votes
2answers
72 views

How is IFS really rendered?

I've read bash manpage and other docs, but I find the explanation a bit confusing. I have the following simple script: #!/bin/bash IFS="" echo $2 var=A B C echo $var if I execute it, eg: ...
-1
votes
2answers
31 views

How to use pass filename without extension to gedit external tool for make?

I am wanting to build and run a program called dbgen using the external tools. I know that this variable holds the filename, ‍‍‍‍‍‍‍‍‍dbgen.c‍‍ : $GEDIT_CURRENT_DOCUMENT_NAME How do I remove the .c ...
0
votes
1answer
42 views

List all file extensions in an arborescence and count number of occurences of each [duplicate]

I am looking for a simple shell function (bash prefered) to list all file extensions in an arborescence and count the number of occurences of each. For example, list_extensions . would return ...
0
votes
1answer
53 views

How can I populate an array in Bash Shell script loop

cmdline> ls -la /.myScript.sh set index=0 set usrlist[index]="null" while read line do #Total lines read z=`echo $line| wc -l` lines=`expr ...
12
votes
5answers
219 views

Why is my Bash script returning a syntax error? [duplicate]

I am writing a script which loops into recent files in a folder and executes a command... #!/bin/bash cd /home/Downloads recent_files = ($(ls -t | head -20)) for file in "${recent_files[@]}" do ...
-1
votes
1answer
59 views

what is shell script? [closed]

Is that some thing like a programming language? Which does provide this option(facility) by a program running on linux or basic program that comes with linux kernel?
0
votes
1answer
55 views

How can I use sed to print out unique users [closed]

I wish to print out the unique users in the system using only sed, using: ls -la | sed '/^$USER$/p' .... It gives me all files, matching to the current user, and prints out the lines they are in. ...
0
votes
1answer
25 views

Filtering Log Output on Separate Lines

I did a recursive grep in a directory to find all files that would match as follows grep -ER "match_string1|match_string2" /path/to/dir/ What I get as output is: ...
2
votes
1answer
127 views

bash time with nohup

I want to know how much time it takes to run something in nohup. I know this works: $ time sleep 2 real 0m2.001s user 0m0.000s sys 0m0.001s But why it doesn't work with nohup? $ nohup ...
0
votes
1answer
34 views

doubts in file system hierarchy? [duplicate]

explain the difference between /bin and /usr/bin used in Linux?
0
votes
0answers
39 views

include Forking - Multi threading in bash script to run it in upstart?

I have lack of understanding. Do i need to include forking in my bash script: http://stackoverflow.com/a/26756839/4749164, so i can use expect daemon/fork - option in upstart? i would like to run my ...
4
votes
2answers
58 views

How to kill a bunch of jobs based on ps output?

Here is output from ps: $ ps aux | grep blob ubuntu 4286 0.0 0.1 34748 9592 ? S Jan14 0:00 /usr/bin/python /usr/local/bin/pynt start_blob_reader ubuntu 4287 0.0 0.1 34748 ...
0
votes
0answers
42 views

Using brew: curl version error, “Incompatible library version” for libcurl.4.dylib

I used to have a working version of homebrew but then something broke today related to curl and libcurl.4.dylib— possibly a version or file location issue. I'm on Mac OS X 10.9.5 (Mavericks). For ...
0
votes
1answer
49 views

What's the best way to make a bash function in a script as a parameter when running via command line?

I'm fairly new to bash scripting, and wondered what's the simplest way to make bash script functions in a script as the parameter when run via command line? Example usage: ./myscript function1 ...
0
votes
1answer
48 views

Log output from more than one script

I have a problem concerning the logging of a process: I have 3 scripts, a.py, b.py and c.sh a.py calls b.py and b.py calls c.sh The goal is to continuously log std out/err (write to file and ...
5
votes
3answers
85 views

How to undo changes in the commands-history?

In UNIX systems you can press top and bottom arrows to navigate through the previous commands. This is extremely handy. Sometimes, I go up and find a command that I want to use again, but with some ...
2
votes
2answers
33 views

universal help/man command: help builtin partial matches

I found a nice little script which iterates through a couple of manuals for a specific command. As a last resort, it will Google it and open a browser window. Source here: ...
0
votes
2answers
65 views

How to use 3rd variable in BASH for loop?

Good day. I want to parse data of particular columns from several files(aprilPlate.txt, mayPlate.txt, junePlate.txt, julyPlate.txt, augustPlate.txt) using For loop. The data of input files ...
0
votes
2answers
43 views

How to grep from command line for theses multiple strings?

I need to run a command to grep one of these strings from command line as web host disabled account to run website from browser until virus files are removed and I managed to collect few strings that ...