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

learn more… | top users | synonyms (2)

2
votes
2answers
63 views

What do i have to consider to write a script that reacts on a keypress?

I know i can read within a script something into a variable, like this: variable = read But i have to press enter in order to submit the value into the variable. What do i have to know in order to ...
0
votes
0answers
20 views

checkbox to automated sql scripts run

I want to provide a menu in a shell script that offers a check list of SQL scripts to run. I actually need to execute the selected SQL scripts but it's about 20 of them and that make it hard to cover ...
1
vote
1answer
78 views

bash script problem when run from desktop launcher

I have a script which does the following: Connect via sshfs to a directory on a server Within that directory, there is an encrypted volume. Open it to the device mapper. Mount to a local directory ...
1
vote
0answers
24 views

Service script and shared libraries

I have the following simple script IPN in CentOS 6.5 in /etc/init.d/ #!/bin/sh # chkconfig: 2345 05 06 cd /root/IPNHost . /etc/rc.d/init.d/functions start() { echo -n $"Starting..." ...
0
votes
0answers
38 views

What is “Source Code For a Script”?

I am brand new to the Unix/Linux world and have a very rudimentary question for you. I am working on writing a shell script and towards the end we are told to "copy your source code for your script ...
1
vote
1answer
55 views

How can subtract 2 floats which have been extracted from 2 other files with BASH [duplicate]

I'm trying to get the difference between two numbers which I have taken from two files. I think my code will make sense: I've tried to make it work by two different methods, didn't work. What I get ...
1
vote
1answer
27 views

Non-block poll from two pipes?

Here is what I want to do.. mkfifo infrequentlog frequentlog sort -m infrequentlog frequentlog > mylog funcA > infrequentlog funcB > frequentlog So that when monitor tail, I can see the ...
0
votes
2answers
69 views

Not managing to make AND operator work in bash script

I'm trying to make a rather simple bash script where if the input is "on 1" it will execute an action and if it is "on 2" it will execute another action. I did a bit of googling about to find out how ...
2
votes
6answers
94 views

Scripting to split a single CSV row into multiple

I need a script that can take a CSV file with that has a column of semicolon-delimited attributes, and break it into multiple rows to normalize that multi-valued attribute? Here is the scenario: ...
1
vote
1answer
62 views

exec redirects in bash

I write a lot of non-interactive scripts where I would like all output to go to a log file and have nothing appear on-screen. To solve this, I've been using: #!/bin/bash exec &> logfile echo ...
1
vote
1answer
41 views

How to correctly deploy/install scripts?

I've developed several utility scripts that solve specific problems of my team's day-to-day work. Up to now, what I have done to deploy the script in my co-workers' laptops is as follows: Every ...
0
votes
2answers
28 views

Unix how to loop through directories, send output to another directory with base name of input file

I am an infrequent user of UNIX, I'm sure this will be fairly trivial for any regular user so I appologize for that. I have the following code: for file in /home/sub1/samples/aaa*/*_novoalign.bam ...
0
votes
2answers
44 views

How to use variables properly in this little script?

Here is a little script to retarget old-wrong symlinks that I want to make interactive. #!/bin/bash # retarget (broken) symbolink links interactively echo -n "Enter the source directory where ...
0
votes
2answers
54 views

Downloading images from csv file to a folder based on its id

I have a csv-file that looks like this (short example, there are actually about 20 images per id). ...
-1
votes
2answers
27 views

trying to reproduce “Unknown test operator” on HP-UX

HP-UX **** B.11.31 U ia64 ***** unlimited-user license LINE_COUNT=`wc -l ${LOG_DIR}/file_transaction.log` if [ ${LINE_COUNT:-"0"} -ge 10000 ] then mv ${LOG_DIR}/file_transaction.log ...
1
vote
1answer
41 views

How to use bash shell for gnuplot to show Greek letter?

I want to write a bash shell for gnuplot to produce figures automatically. But my figure includes Greek letters inside. I have known their ASCII number, how can I show them correctly in figures after ...
2
votes
2answers
46 views

Find and rm command not obeying exclude list occassionally

I am running a find and rm -rf directory list modified earlier than 7 days with an exclusion list of directories which should not be deleted at any case. This is the script excerpt find ...
0
votes
2answers
168 views

YAD and Zenity - Input Start/Stop Times to Trim Video

I have a bash script and a php script that function in concert to trim audio/video files using start/stop times. PHP script: <?php // Create datetime objcects $dt1 = new DateTime($argv[1]); $dt2 ...
2
votes
0answers
36 views

Why is bash -c cutting off the end of my script? [duplicate]

I have a simple script, that is essentially a list of dpkg -i ... commands in a chroot. It looks something like this: chroot /path/to/chroot /bin/bash -e << EOF cd /opt dpkg -i package1_* ...
0
votes
1answer
48 views

Exit /dev/tty after error message

I run this bash function when a button is pressed, it calls my mobile, however when the call ends or I reject the call, it hangs in /dev/tty and does not return to the main program call.sh ...
4
votes
1answer
93 views

Is there anything equivalent to getch() in ksh?

I am writing a script in Korn Shell, where at one statement I want something like getch() used in C. I want my while loop to be exited, if it sees that I have pressed ESC in Keyboard. For eg. while ...
1
vote
3answers
90 views

How to pass an array to a function as an actual parameter rather than a global variable

Is there a way to pass an array to a function as one of its parameters? Currently I have #!/bin/bash highest_3 () { number_under_test=(${array[@]}) max_of_3=0 for ((i = 0; ...
0
votes
1answer
19 views

What is the meaning of “${name##*/}” in Shell [duplicate]

I have a code as while read name; do uuencode "$name" "${name##*/}"; done but I do not understand what is meaning of ##*/ in "${name##*/}" Google doesn't give good results. Can someone please ...
2
votes
2answers
97 views

How do I have sed only perform actions on the first match?

I have a bash script that extracts headers from the MIME Source of an email. The idea is that I only want to capture the headers of the message nothing else. It's not quite working right though. I ...
0
votes
2answers
51 views

How to run a script to get certain contents of a file

So say a file has the login data for a bunch of users: bobby activityname 2014-05-12(bobbymiller@gmail.com) bill activityname 2014-06-12(bobbymiller@gmail.com) bobby activityname ...
0
votes
0answers
41 views

Bash - Convert escape character colored text to BBCode

I want to convert a terminal escape-character colored text file to BBCode colored text. For this i've created an Android logfile with logcat -Cd > /sdcard/logcat.txt. The -C switch adds the color ...
0
votes
2answers
67 views

In a shell script, How to give a variable another value after one job is done?

I'm trying to make a script which will see if the directory exists and will zip all of its contents under it according to the name/path of the directory. The farthest I could go was - ...
8
votes
4answers
397 views

How can measure how long it takes my script to run AND include that in an email it generates?

I have a simple bash script that runs a series of checks (ping, nslookup, etc) and then sends an email report with the output of that data. I'd like the email to include information on how long it ...
3
votes
1answer
38 views

Create list of folders with a matching (but not identical) ending

I have a directory that contains folders ending in .ctpre or .ctpost (e.g. "15.ctpre"), along with other files/folders. I want to make a list that includes only subjects with both pre and post ...
-3
votes
2answers
60 views

SSH with no password

I have a Shell bash file that i run as sudo and it contains a file to send a ssh comand to bulk clients but it asks for the password every time and i do not what key based ssh the password is the same ...
2
votes
0answers
13 views

Get git branch from several folders/repos

I have a folder with several repositories inside. Is there any way I can run git branch or whatever git command inside each folder? $ ls project1 project2 project3 ...
5
votes
3answers
98 views

Split an input for different command and combine the result

I know how to combine the result of different command paste -t',' <(commanda) <(commandb) I know pipe same input to different command cat myfile | tee >(commanda) >(commandb) Now ...
0
votes
0answers
20 views

Help and/or info comand simple

How can i write information for a shell file that i have in my bin to write the information that the help command or the info command use. p.s. can you answer the question with simple steps or code ...
1
vote
5answers
73 views

Comparing float values in bash

My if expression always evaluates to TRUE somehow. ROTATION variable is 0.000 or 90.000, a float value or it seems so ROTATION="$(mediainfo --Inform="Video;%Rotation%" $VIDEO$ORIGINALEXTENTION)" echo ...
0
votes
5answers
60 views

sed to replace with backspace

I have trail.txt, which contains spice netlist. Now I want to replace all expanded parameters to one line only i.e. remove + and append that line to previous line. trail.txt data + net06706 ...
0
votes
0answers
35 views

Issue with a script launching URL, then pkill firefox after X seconds with cron job

I am trying to create a shell script that will start firefox on a certain URL, then kill it 120s later. I have a script that mostly works and a bad crontab job that doesnt seem to. testscript.sh: ...
2
votes
3answers
69 views

Help with script over a list of files

I am using the following command mkvmerge -o newfile.mkv 1.mkv +2.mkv +3.mkv +4.mkv etc... this command collates the video files in the list. Usually I have this files in a folder, the ...
0
votes
0answers
120 views

Using chown $USER:$USER inside bash script

In a small bash script I'm running I am attempting to chown a new directory that is created. I've added: sudo chown $USER:$USER /var/www/$sitename sudo chmod 775 /var/www/$sitename after the line ...
0
votes
0answers
15 views

ftp files share folder need email notications when customer upload and unload files

We are hosting ftp file share folder, is there a terminal script to send email notifications to different people (email Address) when they download or upload on a certain folder, Were running mac mini ...
10
votes
3answers
791 views

What does `1>>` and `2>>` mean in a bash script?

I have the following bash script, from what I understand >> is used to append the output of a command to an existing file instead of overwrite, but what is it doing in this case? This script is ...
1
vote
3answers
128 views

Shell script to delete multiple files

So, I have a file which contains a list of hundreds of files that need to be deleted from various directories. I figured the easiest method would be to create a batch file but I'm not having great ...
0
votes
2answers
43 views

Rename file by it is folder name

I have a sort of folders (A,B,C,D,E,F,G,H) and I have one file in every folder has the same name in all the folders (file.txt) but the size of this file is different from folder to folder. I wanted to ...
0
votes
1answer
51 views

Ambigous redirect done >$2

I have finished my bash script but I am still getting two errors. I've also searched for related issues but none worked: #!/bin/bash avem_element () { local e for e in "${@:2}"; do [[ "$e" == ...
0
votes
0answers
26 views

Bash script results in errors like “: command not found”. Using Sublime Text to edit the file in Windows [duplicate]

I had a ~/.bash_profile which I wanted to move to somewhere where it'll be executed for all users, including the root. I was led to /etc/profile which worked great. I appended my script there and it ...
1
vote
0answers
29 views

In bash instead of creating new line changing the already made line [duplicate]

Ok hard to explain in few words so I was wondering how instead of creating a new line......like lets say I want to: while true; do echo "hello"; sleep 1; done then I want it to count the number of ...
3
votes
6answers
112 views

redirect output to specific line number

I want to grep certain lines by keyword and redirect the output to specific line number of an existing file. Command grep "key" temp_file >> desired.txt What I need is that I can append the ...
3
votes
5answers
903 views

Lots of elif, is there a better way?

I have a Bash script that looks like #!/bin/bash # FECHA=`date +%j` if [ $FECHA -eq 40 ] then echo "Esta semana le toca preparar el café a Osvaldo" | mail -s 'Café' mailgroup@somedomain.mx ...
1
vote
3answers
66 views

Cronjob doesn't execute shell script, but when I am executing it standalone it works. Why?

Shell Type: >echo $SHELL /bin/ksh Cronjob : 15 * * * * /bin/ksh /wls_domains/resMGT/logs/bea/wlr3queuetransaction.sh > /wls_domains/resMGT/logs/bea/data/script.log The script is as below: ...
4
votes
4answers
165 views

list folders and their content

I'd need a file reporting for each folder the content and the name of the folder itself. If I do ls -l * I have (this is just a subset of hundreds of folders) ...
0
votes
1answer
46 views

How to capture return code (not exit code)

I have a script that execute some process and return a number based on the job status. This script is triggered on the back background. i.e. ksh -x myscript.sh 20150102 & My question is how ...