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

learn more… | top users | synonyms (2)

2
votes
3answers
124 views

Processing input line by line (with empty lines) from shell

In a shell script, I need to parse the output of a command line-by-line. The output may include empty lines, and these are relevant. I am using ash, not bash, so cannot resort to process substitution. ...
0
votes
3answers
35 views

Error when trying to accept a directory path as a command line argument

I'm trying to accept a directory path as a command line argument in order to check recently changed files - not too sure if I'm doing it correctly: script=$scriptpath find . "$scriptpath" / -user ...
2
votes
1answer
40 views

Rotate image if width is greater than a value (i.e in pixels)

I was trying to rotate few hundred images which have 7000px height in 1000+ images how to rotate them from bash.
3
votes
4answers
759 views

Bash (Ubuntu) - Strings in while loops?

I am trying to create a while loop in bash that won't continue until the user enters the word "next". I can't seem to figure out how to use strings for the condition though. #Beginning of code ...
1
vote
3answers
516 views

Read longest line in file using while read loop?

I've been googling but I can't find any scripts that uses the while loop to read the lines. I'm stuck and I'm not sure on where to start Heres the question: Write a bash script longestline.sh that ...
1
vote
3answers
290 views

Compare two .csv files

I have two files: 'file1' has employee ID numbers. 'file2' has the complete database of the employees. Here is what they look like: file1 123123 222333 file2 111222 Jones Sally 111333 Johnson ...
0
votes
1answer
71 views

While loop stuck in infinite loop

I cannot figure out why this function gets stuck. What I am trying to do is create a folder from a predetermined start date up until the present month. Unfortunately it completes all the folder ...
2
votes
3answers
209 views

What is the purpose of a start up script? [closed]

So far I know the basic meaning of a script, it is a file containing shell-commands made executable by chmod +x file and able to be run by ./ file. My friend told me, he had to copy so called start ...
0
votes
1answer
144 views

nvm command not available in bash script

I am trying to build a script in in which nvm and eventually node will get installed. I have installed nvm with cURL. I see the modifications in the .profile or .bashrc file (both work) and when ...
2
votes
2answers
73 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
44 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
101 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
35 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
42 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
184 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
32 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
81 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
128 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: ...
2
votes
1answer
83 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
53 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
51 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
50 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
84 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
39 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
59 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
50 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
228 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
82 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
138 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
139 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
21 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
115 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
55 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
50 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
80 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
472 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
40 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
66 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
18 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
115 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
23 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
87 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
84 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
64 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
70 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
243 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
24 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
857 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
291 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 ...