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

learn more… | top users | synonyms (2)

0
votes
1answer
17 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
0answers
4 views

Adjust a script to get the 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
32 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
20 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
21 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
51 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
40 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
25 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
55 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
28 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
31 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
42 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
43 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
64 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
286 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
39 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
47 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
152 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
35 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
47 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
41 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
38 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
36 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
574 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
55 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 ...
0
votes
3answers
42 views

combining n number of files with cat command

I have n number of files, I have stored filenames in a list and I want to combine them. I am doing this manually, i.e. If n=3 cat ${filename[1]} ${filename[2]} ${filename[3]} > newfile If the ...
0
votes
2answers
30 views

Bash script error [closed]

I created this bash script based on answers I found here: If [[ $(autorep -J jobname | cut -c108-110 | sed -n '/ST/!'p | sed '/^$/d' | sed -n '/_/!'p) == *ST* ]]; then echo "Status is Started" fi ...
-1
votes
0answers
27 views

Request a second available IP from the DHCP server? [closed]

I have 3 servers A, B and C that already have IP addresses assigned by the DHCP server. I wanted to request a fourth IP from the DHCP server that I can use as a floating IP between my service. Is ...
0
votes
1answer
24 views

Script to remove certain span elements from an HTML file

I want to write a script that completely removes every instance of a particular span class from a given HTML file. For example, if my undesired span class is "foo" then running my script on the file ...
0
votes
2answers
56 views

sed in while read loop doesn't complete commands

I have a test file called testPage with the following text: || '''Title1''' || '''Title2''' || '''Title3''' || || Cell11 || Cell12 || Cell13 || || Cell21 || Cell22 || || Cell31 || Cell32 || || Cell41 ...
0
votes
2answers
25 views

awk edit column value if numeric

What I would like to do is search for lines where the first column does not begin with 'rs' or 'chr' THEN if those lines begin with a number, append 'chr' to the first column value, otherwise leave as ...
0
votes
1answer
29 views

DNS Query Script

I am trying to get all the A records for some domains. The best way I have found is to use https://www.whatsmydns.net and the nexcess tool. The issue is that it is very slow to copy paste them and ...