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

learn more… | top users | synonyms (2)

0
votes
1answer
8 views

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

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
3answers
66 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
0answers
16 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
48 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 - ...
4
votes
4answers
248 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
30 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
48 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
7 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
4answers
65 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
19 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
votes
0answers
22 views

license notices on code files [on hold]

What type of notice should I put at the to of my code. I want to be that they can make no modifications or re distributor without my permission.The Files are bash so .img and some .py and also some ...
1
vote
5answers
59 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
44 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
16 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
66 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
62 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
7 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 ...
8
votes
3answers
654 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
77 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
30 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
41 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
25 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
26 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 ...
2
votes
5answers
66 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
883 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é' [email protected] ...
1
vote
3answers
54 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
157 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
0answers
40 views

Need a Bash Script [closed]

I have two URLs, which gives the result if the device is active or disable. Example : http://193.168.1.10/status.txt The above URL gives text Status of device is Enabled The other URL ...
0
votes
1answer
37 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 ...
0
votes
1answer
66 views

“too many arguments in [ (test) statement”

this is my first "if-else" script on linux. It gives the error [: too many arguments Code: n=0 if [ $n % 2 -eq 0 ] then echo "even number" fi How to correct it.
-1
votes
0answers
38 views

How to validate the 2 arguments in shell script [closed]

I want to run the shell script with passing the 2 arguments. Like below ./test.sh hostname username And I need to validate the argument within my shell script. How to validate the 2 arguments in ...
0
votes
2answers
67 views

print IP address with interface name

I want to show the IP address like below lo : 127.0.0.1 eth0 : 192.168.5.123 eth1 : 192.172.0.212 wlan0 : 10.1.0.124 I'm able to print all IP address by ifconfig | awk '/inet addr/{print ...
4
votes
1answer
56 views

Unix: Problem with cmp command

Let me give you an idea of what I am doing. I am running a script that is doing basic OS processes for two systems Linux and SunOS. Well the first directory it runs is called sol0. The script puts ...
0
votes
1answer
23 views

v4l2-ctl error in script

I can use v4l2-ctl in command line like these: v4l2-ctl -d /dev/video1 -c focus_auto=0 v4l2-ctl -d /dev/video1 -c exposure_auto=0 But it has error when I run them as a script in a file. for example ...
1
vote
2answers
69 views

Creating a shebang pointing portably to an interpreter in the folder of a script

I have a JS file (file.js) that I want to have executed as a command line shell script through nodejs (iojs actually); I'm using MINGW Git Bash on Windows. The standard way to do it is to put the ...
-1
votes
6answers
62 views

Find all numbers not in a range

I have a file with following content :- 2 4 5 and have range, say 1 to 5 . I need a shell script whose output will be 1,3. That is the numbers which are not present in the file and within the ...
2
votes
1answer
26 views

Intercept and modify commands in bash scripts

I have some scripts and some commands in the scripts are like this ./executable arg1 arg2 .. argn I want to change the above command to LD_PRELOAD=/some/lib ./executable my_arg1 my_argn arg1 arg2 ...
3
votes
2answers
45 views

Execute command after inotifywait established watches

Inside shell script (test.sh) I have inotifywait monitoring recursively some direcotry - "somedir": #!/bin/sh inotifywait -r -m -e close_write "somedir" | while read f; do echo "$f hi"; done When I ...
0
votes
1answer
39 views

Crontabbed shell script not able to create/write to a file

I have written a simple shell script to backup the tables in my DB using the mysqldump command. The command simply dumps the DB into a dbName.sql file. However, if the dbName.sql file doesn't already ...
1
vote
2answers
42 views

add a new line to a delimited file

So I have a file name test.txt inside that file I have about 20 lines of text that are delimited by pipe | Example: John|freshman|seatle|math|4|fulltime Bob|senior|Tacoma|biology|4|part-time I ...
-1
votes
0answers
23 views

helping get a shell script right from github

I came across this script on github. https://github.com/loganbraga/dotfiles/blob/master/bin/runOrRaise #!/bin/bash if [ $(pgrep $1 | wc -w) -gt 0 ]; then if [ $1 == "iceweasel" ]; then wmctrl ...
1
vote
0answers
32 views

Questions about whiptail and bash functions

I'm a bash newbie. Say I have this script #!/bin/bash function cpp-lang { yum install "Development Tools" } function updatesys { yum -y update yum -y upgrade } whiptail ...
4
votes
4answers
544 views

How create a temporary file in shell script?

While running a script, I want to create a temporary file in /tmp directory. After execution of that script, that will be cleaned by that script. How to do that in shell script?
0
votes
2answers
31 views

Setting up a script on an AMI box to create directories - vsftpd, pam, mysql

I'd like to first say I'm a noob when it comes to linux, so please excuse my confusion. I'm trying to setup vsftpd on a amazon ami 64 bit box, free tier micro. Following these instructions, ...
2
votes
2answers
249 views

How do I use a function return as a condition of an if else then shortcut?

There are instances where a function needs to execute and return to the caller and this works for me. if tst; then echo "success" else echo "failure" fi function tst () { return 0; } ...
1
vote
1answer
41 views

split line based on space and delete the second part

I have a big file >fid|29290408|locus|VBIEntCas2262_0001| Phosphoglycolate phosphatase (EC 3.1.3.18) [Enterococcus casseliflavus EC20] ...
1
vote
2answers
52 views

Copy the first 2 lines from a file and then remove the lines

I need to process a file using a shell script. The file arrives with the data as well as some embedded information releavant to how it is processed. The file is in the following format; ...
0
votes
1answer
30 views

Error while running script with nohup

I got this error while running my script with nohup sh: syntax error near unexpected token `(' My script is as follow: #!/bin/bash report_log="report.log"; grep -A 3 'successful\|ERROR COUNT ...
-1
votes
1answer
37 views

multiple input in a awk file

Please guide me to get out of it. Thanks in advance. I am having a situation that I have to write a awk script which takes the input of two .out files and generate a single .txt file. $ cat ...
2
votes
1answer
47 views

How do I securely download files in shell scripting?

I am writing some shell scripts to automatically download software packages off my server and set them up on customer servers. At some point within the script, the download command is wget ...