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

learn more… | top users | synonyms (2)

0
votes
0answers
21 views

Passing variables through <<EOF

fdisk /dev/$ROOTDISK <<PARTCMD d $ROOTPARTNUM n p $ROOTPARTNUM PARTCMD How can i pass the $ROOTPARTNUM variable?
0
votes
1answer
21 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
17 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 - ...
0
votes
1answer
15 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
12 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
38 views

How to replace words in a string which has “|” in it

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
39 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
61 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
33 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
275 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
36 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
42 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
33 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
24 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
21 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
34 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
24 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
33 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
46 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
35 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
148 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
32 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
47 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
43 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
36 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
36 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
571 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
29 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
25 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
22 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
1answer
49 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 ...
0
votes
2answers
38 views

awk if-then-else statement error

I am writing an if-then-else statement using awk in a bash script. What I would like to do is identify lines with col 1 values not matching a particular string (rs or chr) and append a prefix (chr) ...
0
votes
0answers
11 views

Zenity. How to run as an application?

I built a script (bash), then I overlaid it with Zenity (to have a progressbar in a GUI for non linuxian users). How can I deliver it as an app, not a .sh ? And never show a square of terminal ?
0
votes
1answer
16 views

Is there a GUI debugger for csh script?

I have read another question in UNIX & LINUX stack exchange. The GUI provided in that question can be used to bebug *.sh file. How about to debug *.csh file? What other plugins for eclipse can I ...
1
vote
1answer
82 views

'while read line do' cause: “syntax error near unexpected token `done'” in Linux bash script

I have a shell script which is running fine on Solaris platform but not working on Linux platform. The Failing code snippet is as following: [...] while read line do insert_into_table="insert into ...
1
vote
1answer
46 views

How can I replace the <title> element in many HTML files?

My directory ~/foo contains many HTML files. Each one has a different unwanted title element. That is, each file contains the code <title>something unwanted</title> Many of these files ...
0
votes
2answers
24 views

Bash script to edit lots of html documents

I have a directory with many HTML documents. Most of them contain the codeblock .org-link { /* org-link */ color: #b58900; font-weight: bold; text-decoration: ...
0
votes
0answers
50 views

Shell Script how to approach the below scenario mentioned?

I am working on a task. Description: From a csv/txt file I have to read each line(each line has a unique number eg :1-123456781234-xxxxxxxxx) I have to fetch each line(each unique number) and do a ...
0
votes
2answers
50 views

Bash script that removes part of a filename in every file under a directory

I have several files under a directory whose names are of the form *.foo.bar. I would like to write a bash script to rename each of these files by removing the .foo part. For example, suppose that ...
0
votes
1answer
20 views

Running repetitive task through Bash script

I'm running a few repetitive tasks and I think will be good to create a small bash script to perform all them in just one command: run the bash script. This are the tasks I need to run: # stop HTTPD, ...
-1
votes
1answer
51 views

script with no arguments should echo a message, but it doesn't [closed]

I'm questioning why my script still does not run the condition when no argument is provided. I think it might be the ordering of my if statements but I'm not sure. Any advice? It doesn't seem to be a ...
1
vote
1answer
46 views

Script SSH and run command

I must connect to server every day by ssh, and I made a script to display logs. This is my code: #!/bin/bash A=`date +%Y` M=`date +%m` D=`date +%d` gnome-terminal --geometry=82x11 \ --tab --title ...