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

learn more… | top users | synonyms (2)

0
votes
1answer
22 views

Sudo Apache, with command line ? (not visudo)

I have visudo-edited /etc/sudoers this way: User_Alias APACHE = www-data Cmnd_Alias FIREWALL = /sbin/iptables, /sbin/ifconfig, /sbin/route APACHE ALL = (ALL) NOPASSWD: FIREWALL (To allow php ...
0
votes
2answers
19 views

link cut, find length and cut the new text with the first text's length

I'm stuck up with the below situation. there are two files - sample.war & sample1.48.war now, I've to cut only the first field of the first file. i.e., 'sample'. Next, I've to count the total ...
0
votes
3answers
35 views

Shell Script to change locale has no effect

I wrote a simple script to switch my locale. If I write each line in the console and execute it, it works without any problem or if I put it in .bashrc. However when I execute the script either with ...
0
votes
2answers
31 views

Find the time of the file received in a particular directory

I have a directory called /home/mydir/test A file will be sent from some other team which lands in this directory. How to find what is the time the file came to this particular directory? ( I need ...
1
vote
1answer
35 views

Pass list of directories (that contain whitespaces) to a command in a script

For example, I want to execute the following within a shell script: tar cvpzf /destination/backup.tgz /directory\ one /directory\ two I wish to assign the list of paths (with whitespaces in them) ...
0
votes
2answers
65 views

Why does this command not remove files as expected?

This command in my .sh script is supposed to look in /home/backup/VBtest for .sql.gz files and remove any older than 5 days: find /home/backup/VBtest/*.sql.gz -mtime +5 -exec rm {} \; But it ...
0
votes
1answer
28 views

how to trigger sms from unix (shell script) [on hold]

How can I trigger an sms once a command is executed using shell script? for eg. cat file (one above command is executed (irrespective of the result), I should get an SMS
0
votes
1answer
20 views

Replace the first word of each line with its MD5

I have file with two space separated word in each line. I am looking for shell scrip in Unix to replace the first word of each row with its md5 hash representation. I have tried to adjust what is ...
0
votes
1answer
17 views

Adjust a script to get only certain rtvscand output report

I have the following working script: for i in `cat list` ; do ssh root@$i "uname -n ; cat /opt/Symantec/virusdefs/definfo.dat ; service rtvscand status ; echo ...
0
votes
1answer
38 views

What means echo“{@@##}”?

We got a script that we need to understand, and at some point, we got this syntax: if [ "$PASS_CHAINE" = "TRUE" ] then echo "Launching DEGAGEMENT" | SLog cd $INTERFACE_D/bin_cm/deg ...
-2
votes
1answer
22 views

copying a text from one file and pasting into other using shell script

I want to copy the number in a particular line from one text file and paste that number to other text file, how to do this using shell scripting. For example in file1 I have a line Total Time: ...
1
vote
1answer
22 views

How to timeout and exit, if a sql query takes more than 10 minutes to get the results

I want to execute a select or update query. Sometimes the result is not fetched on time. As per requirement in different test conditions, I have to fail the tests if I dont get result in 5 minutes or ...
0
votes
2answers
58 views

how to run multiple commands with awk via ssh?

I am having difficulty on the command below. Something is not right with the awk command. I tried putting backslash but still no good. Anyone can pin point where is my syntax gone wrong? for i in ...
1
vote
1answer
24 views

Detecting file size and do operation conditionally

In my main_dir, I have a lot of sub-folders say DFT1 to DFT150, and in each directory, there is a file named OSZICAR. However, some of this would have file size 0. So I would like to have a script, ...
0
votes
1answer
42 views

Pushing to a Git repo from shell script

I'm trying to commit/push changes to a remote Git server with the below sample code: #!/bin/sh USER='username' REPO='/home/'${USER}'/Sites/git/bitbucket/kb' COMMIT_TIMESTAMP=`date +'%Y-%m-%d ...
0
votes
0answers
27 views

shell script in doing operation for 2 folder tree [duplicate]

I have a directory looks like: dhcp-18-189-47-44:CE-06-new-stuctures_backup wenxuanhuang$ ls DFT-00001 DFT-00004 DFT-00007 DFT-00010 DFT-00013 DFT-00016 DFT-00019 DFT-00022 DFT-00025 DFT-00028 ...
0
votes
1answer
26 views

extract subfolders outside and rename if necessary

I have a directory looks like: dhcp-18-189-47-44:CE-06-new-stuctures_backup wenxuanhuang$ ls DFT-00001 DFT-00004 DFT-00007 DFT-00010 DFT-00013 DFT-00016 DFT-00019 DFT-00022 DFT-00025 DFT-00028 ...
0
votes
1answer
21 views

How to spawn new processes for new instances of the same shell script?

I'm trying to lock a file using the command lock. It's syntax is ./lock </path/to/file/name> I need to lock a bunch of files in a given directory and in order to achieve this I'm using two ...
0
votes
0answers
37 views

Passing variables through <<EOF [on hold]

fdisk /dev/$ROOTDISK <<PARTCMD d $ROOTPARTNUM n p $ROOTPARTNUM PARTCMD How can i pass the $ROOTPARTNUM variable?
0
votes
1answer
58 views

How can I merge 3 commands and execute them

I'm try to run a script that figures out the paths based on the hostname: e.g. if hostname returns computer1 I would like to run path/to/Computer1.py (where path/to is a path that will always be the ...
1
vote
1answer
29 views

How reliable/portable are Nix built-ins/commands (echo, ps, sort, uniq) from Debian to other distros

I've coded a script and am wondering about it's reliability / portability. #!/bin/bash threadsPlease() { ps -mo lwp,c -p $1 | sort -gk 2 | uniq -f 1 } THREAD_LINE=$( threadsPlease $1 | grep -v - ...
1
vote
1answer
34 views

Pass shell variables to SQL statement

I want to pass shell variables to sql statement. Both shell script and SQL statement are present in the same script file. I want the values of the variables retMonth, retLastDay and retPrvYear in the ...
0
votes
0answers
17 views

How to display/change text in same window in yad

I wrote an application in Linux using YAD (shell script obviously). In my app when I click different buttons text in --text-info changes (should change). but as for now i could do it only by popping ...
1
vote
0answers
43 views

How to replace words in a string which has “|” in it [on hold]

For example line, in this loop in a shell script: for ((k=13;`awk -v f="$k" -F " " '{print $f}' line$i.txt` != "|";k++)) I want to replace the words in the line from 13th position until a "|" is ...
3
votes
2answers
45 views

process Count of each user in ps aux command

How can i create a script to count process run by each user in ps aux. I used this ps aux | awk '{print $1}' | grep root | wc -l but it lists count of root user only . I want to list number of ...
1
vote
2answers
65 views

Need output in a good format using shell script

I have a file, PoolReport.txt. Here is some sample data: Thu, Aug 27, 2015 7:56:29 AM PoolName,Total GB,Used GB ,Available GB ,Percent Full Oracle-RAID10,6432.539,6179.295,253.244,96.063 ...
1
vote
2answers
50 views

Job control over a Bash script

I have a Bash script of a thousand lines each containing an ffmpeg command. I start this with source script and it runs just fine. However, when I try to take control of this script in various ways, ...
2
votes
5answers
288 views

Get very next word of a substring in a string

I need to get the next word of a word in a string. I tried to write a script but it's not working. And it's good if you suggest me any other alternatives to achieve this. Script: #!/bin/bash ...
0
votes
2answers
37 views

Different behaviour of eval “ command \”$@\“ ”, “$@”, and “$(echo $@)” when used as arguments [duplicate]

I would like to pass multiple arguments to the Tor browser (firefox) programatically through a function arbitrarily entitled tor. This is so as to command tor search terms and voila! My search terms. ...
3
votes
2answers
44 views

How to skip unresponsive server

I wrote a script that runs on multiple servers. Sometimes the script gets hung on one of the servers and I have to hit (control C) to end the process. If not, it gets stuck and keeps trying to ...
0
votes
1answer
36 views

Unable to get actual row counts because of Carriage return values:

I have an input delimiter file.The actual number of records in the file is 4. But due to carriage values now the total count is 8. I just want to do count of rows based on first column values. ...
1
vote
1answer
25 views

rm all files to the right of “==” printed on the screen

I have a script that prints: dhcp-18-189-47-44:CE06_getting_new_fit myname$ ./find-duplicate-structures.sh custom_structures new_GS_calculation/selected/POSCAR_00* ...
0
votes
1answer
22 views

Manage multiple servers

I wrote a simple script that I want to run on several hosts. (I.e., I want to run one instance of the script, but have it operate on several hosts.) The script works, but only for the first host. When ...
0
votes
2answers
41 views

Check if process is running Mac OS X then execute code

I am creating a script which clears the cache for Google Chrome. However, I would like to check if Chrome is open and if so not run the code but if it isn't then it will execute the code. I can see ...
0
votes
1answer
25 views

How to run bunch of hierarchical dummy shell processes (process of another process, etc.)?

I would like to run multiple processes where each process is running another one, so it will create a long process branch. I've tried: $ bash -c '(bash -c "sleep 20"); sleep 20' & $ pstree ...
0
votes
2answers
34 views

Insert text to file using bash scripts (NOT appending)

I want to add text to a file using shell-scripts. The solution I know is if you want to insert your text into a newline (appending): echo "mytext" >> myfile.txt what I want to have a ...
-3
votes
3answers
48 views

Shell Programming Quesiton with Loops Until and While

I need a solution for the below Write a Shell program to print the numbers in the following format: Use While or Until loop for the following program 1 2 3 4 2 3 4 5 3 4 5 6 4 5 6 7 5 6 7 8 6 7 8 9 ...
2
votes
2answers
31 views

How can I send multiple options to one variable

I am running a loop for an array of variables that generates three more variables. i.e for foo in ${bar[@]}; do bar1=$(echo $foo | awk '{print$1}'); bar2=$(echo $foo | awk '{print$2}'); ...
0
votes
0answers
27 views

How do I send a variable through SSH so it can be used across servers? C Shell

EDIT: Would this be possible in bash? Note: I have to use C shell. (.csh) I have something very similar to the following code: set var = "string" ssh -X server "$var" << END * I ...
0
votes
1answer
36 views

How to add a folder to a remote hosts PATH using a shell script?

I'd like to automate the process of syncing a local ~/bin folder to a remote host, and adding that folder to my remote shell's path. I've got the syncing part done, but am not sure how to automate ...
3
votes
1answer
154 views

Exit bash when find gets to a folder with permission denied

I'm trying to write my second Bash script. Where i go through folders recursively and make a list of and count files and folders. In a way it works but if "find" gets to a directory where it has ...
0
votes
2answers
36 views

It is possible to list all files that have at least 3 letters on its name?

I have to find all files that have a minimum of 3 letters, starting with the letter "l". I'm using this, but it also gives me the files with less than 3 letters. ls | grep "^l" Is it possible ...
-1
votes
1answer
48 views

Unix script meaning required

I am trying to run a script in unix. It's a simulation that I need to run for two different months. For that the following portion of the script is vital. Can anyone please tell what it means? set ...
0
votes
2answers
23 views

Replace a second field output with sed or awk

I have a below content in a file where i need to search the pattern "application:" , where "application:" should be there but the next field to it should be changed to "RMAN" , I am trying to do with ...
1
vote
1answer
49 views

How to print the line numbers with corresponding line that matches a pattern using shell command? [duplicate]

File, .false alarm is bla no. 11 .no alarm generated is bla .application will be killed is bla wall command .doc file is document file with .doc extension .no authority for this selection bla Now ...
1
vote
1answer
43 views

Batch renaming of files with ascending number

I have a batch of files: $ ls Li1Fe1O2_11 Li1Fe2O3_8 Li1Fe3O4_2 Li1Fe3O4_5 Li2Fe1O3_16 Li2Fe2O4_12 Li3Fe1O4_19 Li3Fe1O4_22 Li1Fe1O2_14 Li1Fe2O3_9 Li1Fe3O4_3 Li1Fe3O4_6 Li2Fe1O3_17 Li2Fe2O4_13 ...
1
vote
1answer
39 views

Identifying duplicate fields and print both with awk

I have a file with multiple columns and want to identify those where specific column values (cols 3-6) have been duplicated. The following code finds the duplicates but I want to display both ...
0
votes
1answer
37 views

Scripts in rc.local (start at boot), doesnot start

In my Debian /etc/rc.local, I've put 2 scripts (one for Wifi AP, the other for VPN client-connection): sh /bootscripts/vpn.sh & sh /bootscripts/wifiap.sh & #test: date >> ...
4
votes
3answers
575 views

Loop ignores change of variable from a subshell in the background

I wrote a script that contains an until loop. This loop should run till a boolean variable is set to true from outside the loop. Unfortunately the loop ignores that the variable has been set to true ...
0
votes
1answer
57 views

How to grep the following lines from a file?

I have a file which has the names of many files in a directory in the following format: A20150824.0950-0955_jambala_CcnActiveSessionCounterJob A20150824.0945-0950_jambala_CcnActiveSessionCounterJob ...