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

0
votes
0answers
10 views

Help in manipulating a test file

I have a file look like aaa/bbb/ccc.bbb aaa/bbb/ddd.bbb aaa/eee/fff.eee aaa/eee/ggg.eee I would like to skip lines ending similarly(.bbb & .bbb) and add a string only after all occurrence for ...
0
votes
0answers
26 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 ...
1
vote
1answer
26 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
24 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 ...
5
votes
4answers
329 views

Storing bash scripts

What is the good common practice to store shell scripts? (bash, sh, ...) For now, I have a few bash and sh scripts in my $HOME directory and I invoke them with $ bash $HOME/script1.bash arg1, arg2, ...
0
votes
2answers
55 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
0answers
27 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
35 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. ...
3
votes
0answers
13 views

CPU usage of file system operations not shown in top

I run the following command (which does ls for 10,000 times) in a Ubuntu Linux terminal and use the top command to monitor the CPU usage. While top shows the total CPU usage (line 2) is about 48% ...
0
votes
3answers
37 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
25 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
34 views

Loop is not working as it should [on hold]

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
13 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
17 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
0answers
64 views

How to prevent expansion [on hold]

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
34 views

I need to copy lines from multiple files between two dates with date name as file extension [on hold]

This is the code I am using: Get_Timelog() { dialog --backtitle "Welcome" --title "Get Timelog" \ --date-format '%Y-%m-%d' --calendar "Please choose a start date..." 0 0 ...
-2
votes
0answers
30 views

how to copy the lines in multiple files between two given dates [on hold]

The task is this. I need to create a utility which will look for Log info between the dates user specified and copy all that info to a file The Log files are present in your home directory under work ...
1
vote
1answer
90 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:" ; ...
-11
votes
1answer
43 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
30 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
37 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
51 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
-5
votes
0answers
51 views

What am i doing wrong with my script? [on hold]

#!/bin/bash echo echo These are the Users Processes top -b -n 3 | sed -n '6,12p' pid= top -b -n 3 | sed -n '7,12p' | cut -f1 for pid in 'ps -ef | grep $pid | awk '{print $2 }'' ; do kill $pid ; ...
0
votes
2answers
32 views

Getting error with sleep and argument in sh script [on hold]

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
33 views

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

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, ...
0
votes
2answers
36 views

Using braces expansion to specify a set of paths: how to specify general branching principles? [on hold]

So, recently I've become obsessed with making an "elegant" CDPATH that suits my needs. While previously I had no idea you could use anything other than literal strings to define the variable, I ...
1
vote
3answers
53 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
24 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
1answer
36 views

finding a 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. My code is: #!/bin/bash DIR="$1" echo "maximum file size:" du $DIR -h echo "average file size:" du $DIR -sbh ...
1
vote
1answer
58 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
64 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
163 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
20 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
18 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
70 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
26 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
37 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
38 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 ...
10
votes
5answers
93 views

Why is my Bash script returning a syntax error?

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 ...
-6
votes
0answers
31 views

Why changing variable position fixes the error [on hold]

I spent half hour trying to figure out why totusr=`expr $index + $totusr` was giving me syntax error then I did this totusr=`expr $totusr + $index` GUESS what its working.but why ?
-1
votes
1answer
55 views

what is shell script? [on hold]

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
46 views

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

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
21 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
102 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
29 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
43 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
16 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 ...
-1
votes
0answers
29 views

Custom Command not found after sourcing .bashrc [closed]

I wanted to add a function that could create custom alias so I added the following to .bashrc function addalias { echo "alias $1='$2'" >> ~/.bashrc } I then ran source .bashrc I tested ...