Questions about shell scripts, executable files that are interpreted by a shell (bash, zsh, etc.).

learn more… | top users | synonyms (2)

0
votes
1answer
38 views

How to kill a process running in specific script

I have two script files running simultaneously. I just need to kill the java process running in one script without affecting the java process in the another one.
0
votes
0answers
10 views

Mutt multi content type

Good afternoon I want to send multiple content_type with mutt. Can I do that? Here is my code : mutt -e "set content_type=text/html" -e "set content_type=text/plain" someone@mail.com -s "Multi ...
2
votes
2answers
111 views

to compare two fields in two different files

In file1, I have 1023M BLD 123G DEV 945K Deployment 4899 INT In file2, I have 1.2G BLD 123G DEV 345M Deployment 499M INT I wanted to compare the first field of file1 with first ...
1
vote
3answers
36 views

shell script for auto-touching files

I have written a shell script to touch all the files in the /tmp directory. However, there was an error message saying that /bin/touch: Argument list too long. What's the cause of the problem? ...
1
vote
1answer
31 views

How could i flip content of a binary file with bash commands

I was wondering if it's possible to do bitwise conversion on a binary file, with bash commands, (in my case bitwise negation).
0
votes
1answer
32 views

init.d script is not starting under virtualbox

The script is in /etc/init.d: #!/bin/bash VMUSER=myname CURRDATE=(`date +"%m-%d-%Y"` + `date +"%H:%M:%S"`) CURRTIME=(`date +"%X"`) FILE=/home/myname/log/vm-services.log VBPATH=/usr/bin start(){ ...
0
votes
1answer
44 views

Problems copying files with spaces inside the file name in a bash script [duplicate]

I have the following function inside a BASH script (running under Ubuntu 12.x), which would copy over a file with spaces inside the file name. It's not working. I've tried many different combinations, ...
1
vote
1answer
30 views

Killing multiple instances of the script from the script itself

I've couple instances of script.sh running in parallel, doing the same thing, running in background. I'm trying to use a function to kill all the current running scripts when executed. So, for ...
2
votes
1answer
26 views

Calculate Apache's response time for last 10 seconds

I have the next apache's log format: LogFormat "%h %l %u %t \"%r\" %>s %b %D \"%{Referer}i\" \"%{User-Agent}i\"" where's %D - The time taken to serve the request, in microseconds. I want to ...
1
vote
1answer
56 views

Why doesn't this piped script work?

#!/bin/bash rm out mkfifo out nc -l 8080 < out | while read line do echo hello > out echo $line done If I browse to the IP of the machine this script is running on (using port ...
5
votes
4answers
204 views

How to replace all the first occurences in matched lines with incremental number?

I have a file like this ... 1562 first part 1563 H col3 H col4 1564 H col3 H col4 ... 3241 H col3 H col4 3242 third part ... I want to replace only the first H in every line to H#, with ...
0
votes
3answers
83 views

How can I get the pid of a process started this way

#!/bin/bash mkfifo /var/run/out while true do cat /var/run/out | nc -l 8080 > >( while read line do do some stuff done ) done How can I get the pid ...
1
vote
1answer
43 views

How can I kill child processes with start-stop-daemon?

I'm writing a simple web server using nc and bash. It looks like this: #!/bin/bash rm -f /var/run/streamman/out mkfifo /var/run/streamman/out trap "rm -f /var/run/streamman/out" EXIT while true do ...
0
votes
1answer
30 views

How do I validate a settings(ini) file for the values expected using bash?

After I check if the ini file exists where it is expected to be, which I've learned how to do, I would like to check the file for proper formatting. I'd like to validate any number of "site" entries ...
-1
votes
1answer
40 views

Shell scripting enthusiast [on hold]

This may sound generic and non technical to many but i can use some quality advice here. I am an technical support engineer who happens to be interested in shell scripting. My job does not need me to ...
0
votes
2answers
23 views

Editing /etc/init.d/mysql to remove mysql.sock automatically

I am running MySQL on a CentOS release 6.5 (Final) virtual machine. It is used for testing Joomla. The phyiscal host reboots frequently, which is fine. The VM, however, does not perform a clean ...
-2
votes
2answers
35 views

Identifier must be declared [on hold]

Hi I am new to Shell scripting , and I am facing this issue for days, can someone help me out? my snippet : filename='somefile_Connectivity_12345.CSV' trimfilename= echo $filename| cut -d'_' -f ...
2
votes
2answers
66 views

How parse a log file for a string, and when found search backwards for another string

I use the following command to parse a log file for a particular string. Then I search backwards in the log to find the data I really want. The problem as in the example below, I am only going back ...
4
votes
2answers
63 views

Using $ in a password

Lets assume that password of my server is Abcd$1234 I am trying to ftp a file from other server to my server using the following in shell script ftp -inv (IP) << EOF user Username Abcd$1234 ...
3
votes
1answer
160 views

How does the colon sign and dollar question mark combine in sh?

The "colon sign" and the "dollar question mark" can be combined to check if a sh script does have an argument and assigns it directly to a variable of interest: cmd=${1:? "Usage: $0 ...
3
votes
1answer
24 views

X commands do not start from my at job

I'm learning about Linux scheduling commands including at, cron, sleep etc. I'm trying to launch gedit after x minutes via the at command. This is what I have: kedar@i5 ~ $ at now + 1 minute at now + ...
3
votes
3answers
212 views

Preventing a specific space from being expanded in a variable

In bash how do you avoid a specific space from being expanded in a variable? Lets say I have this JAVA_OPTS="-Xmx1g" JAVA_OPTS="$JAVA_OPTS -XX:OnError='/path/to/a/script.sh %p'" function args() { ...
2
votes
4answers
145 views

Execute all files in a list

I have a source tree which, when make is run, produces several executables named "001", "002", and etc. I'm trying to write a script which will find all of these executables in my source tree, and ...
0
votes
1answer
44 views

Using bash's “source” command return error though it successfully read config file [duplicate]

I want my bash script to read parameters from config file. Here is what inside the script: #!/bin/bash source /home/myscript/conf/config.conf echo "$username" and below is my config.conf: ...
3
votes
2answers
82 views

exit a script if an ls line did not find any match

I am writing this script that have this line: ls -lrt /dir1/dir2/filename*.txt | tail -1 | awk '{print $9}' | read variable What I wanted is to exit the script (without using if-statement) if it ...
3
votes
3answers
73 views

Script to email all matching files in a directory

Trying to set up a bash script to automate sending data files. Desired end result is to check a specified directory once per week, make a list of all Excel files modified within the last 2 days, and ...
0
votes
5answers
125 views

Move files to multiple folders [closed]

I've searched for this function, and there are lots of answers, but I haven't been able to find anything that works for me. I have a folder with about 30,000 files, and I want a terminal command or ...
2
votes
2answers
53 views

Why does the while cycle skips and only reads the first line?

$ ls testscript.sh testservers.txt $ cat testservers.txt serverA IMM 10.2.3.4 USERID PASSW0RD serverB IMM 10.2.3.5 USERID PASSW0RD $ $ $ cat testscript.sh #!/bin/bash # test them.. egrep ...
0
votes
3answers
30 views

Shell script to produce duplicate output with increments

I need a script that will produce the following output many times @float Figure,fig:n @cindex @image{n,9cm}. @caption{} @end float but where n (both times) is replaced by 1, 2, 3, up to a large ...
1
vote
2answers
26 views

Bulk rename and resize with Imagemagick

I need to convert a very large number of images that are called 1a.jpg, 2a.jpg, 3a.jpg using Imagemagick to be processed and renamed 1.jpg, 2.jpg, 3.jpg (in the same directory). The Imagemagick ...
3
votes
4answers
268 views

A command that generates both standard error and output

I want to do some troubleshooting on my bash script. Is there a short and simple command that generates both stdout and stderr so that I can use 2>&1 on it? Sorry if this looks trivial, but I ...
1
vote
0answers
39 views

When gnu parallel exit,my program also fail

I use gnu parallel to run a bash function. The function just contains the bash script to restart my program. At first, the restart is ok, but when the gnu parallel script exits, my program also fails. ...
-4
votes
0answers
44 views

“unexpected end of file” error in a bash script [closed]

#!/bin/bash APP_FILE="/tmp/name_file.txt" IPFILE="/tmp/ipaddres_file.txt" PINGDETAILS="/tmp/ping_results" NEWFILE="/tmp/new_file" echo "" > new_file echo "" > ping_results serverup_count=0 ...
3
votes
2answers
46 views

Why is my trap not printing any log message?

What I'm doing is, trap 'rm -f /path/of/file/fileName.running; echo "TRAPPED & READY";' 1 2 9 15 >> trap.log I didn't get anything in log & the file which should have been deleted ...
4
votes
3answers
244 views

How to pass each line of a text file as an argument to a command?

I'm looking to write a script that takes a .txt filename as an argument, reads the file line by line, and passes each line to a command. For example, it runs command --option "LINE 1", then command ...
0
votes
0answers
22 views

authenticate url with asked credentials

there is a URL http://server, when I open this url it ask for username and password (.htaccess authentication), this URL works fine in browser. This is the webpage not the browser which ask ...
0
votes
1answer
38 views

How to start a cron task?

It sounds really simple, but many times I was stuck at the beginning of learning a new command. The tutorial writer think it's natural to start, but it's not. This is the tutorial I've been reading: ...
4
votes
3answers
335 views

pipe line with non-deterministic output

I have happened upon a command that sometimes works and sometimes does not, even when executed multiple times in rapid succession in a bash shell (I have not tested the behavior in other shells). The ...
5
votes
2answers
71 views

Extract tomcat parameters from ps output

I'm trying to write a little diagnostic tool and one of the functions I want from it is that I want to run is: ps axu | grep tomcat | grep -v grep | awk '{ print $<list of desired fields> }' ...
1
vote
1answer
30 views

How to assign words with spaces as a whole name to variable in shell script? [duplicate]

I need to make some directory of Author name. It's easy when doing them alone. I can simply mkdir "Mario Luis Garcia" This will create one directory named "Mario Luis Garcia" But when trying do it ...
2
votes
1answer
464 views

Why is 'kill -9' killing browser as well as server?

I sometimes have to use kill -9 as a last resort to kill my rails server. Unfortunately, I have to do that often enough that I wrote a helper function in my bash_profile to do it. If I do it manually ...
-3
votes
1answer
37 views

How to interleave two files?

How do I take two input files and create an output file that interleaves their contents? For example, if one file contains: 3 4 6 9 1 7 3 4 5 6 3 5 7 9 10 And another contains: a d g e t u v g j j ...
0
votes
0answers
35 views

Updating data sets from Online databases/Webservice

I want to have an idea as to how to update the data regularly from the source, if its stored locally in your server or local machine.Lets say MySQL database. Source:It will be a webservice data ...
1
vote
1answer
43 views

Handling sed variables with paths in them?

I have an applescript for doing certain things, like search and replace. set lol to quoted form of POSIX path of (choose file with prompt "VälJ Fil") That chooses a file then im doing this set ...
3
votes
1answer
27 views

start-stop-daemon returning always 0 (success)

I have set up start-stop-daemon to start my script automatically case "$1" in start) log_begin_msg "starting foo" start-stop-daemon --start --chuid nobody --user nobody --pidfile \ ...
0
votes
0answers
41 views

Connect Unix and Windows using shell script

SRCDIR="source/directory" TMPDIR="temp/directory" [ ! -d "$TMPDIR" ] && mkdir -p "$TMPDIR" for file in `find "$SRCDIR" -ctime -1 -type f -name "abc*pdf*"`; do cp $file $TMPDIR done cd ...
0
votes
2answers
53 views

Shell script to work on files in some directory

I am a noob in Linux hence this might come as a silly question. I have a Windows system, so I downloaded cygwin to help me execute Linux/unix commands. I need to execute a shell script on a bunch of ...
0
votes
2answers
36 views

Getting expr: syntax error on index [duplicate]

Using this OF=$(ps fax | grep 'php-fpm: master process' | awk '{print $1}') IDX=`expr index $OF ' '` I get an error. The results of the $OF variable are: 27797 27495 What is the error here? I ...
0
votes
1answer
30 views

Echoing Total Page Number in Bash Script

I have the following script for batch pdf-ocr processing & it works fine #!/bin/sh # apt-get install exactimage tesseract-ocr ghostscript # bash tut: ...
1
vote
2answers
52 views

Shell script: whole directory to the remote ftp server

I am trying to ftp some recording files to a remote server for backup every night. I am very confused regarding shell script. My question / problem is : I want to move the whole folder/directory ...