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

learn more… | top users | synonyms (2)

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 ...
0
votes
1answer
27 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
30 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
40 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
14 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
17 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
87 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
48 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
25 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
52 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
47 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 ...
1
vote
3answers
73 views

Copy filenames, and add path prefix, in a directory, recursively

I have a working directory: /home/myusername/projectdir The working directory contains files and sub-directories. The depth of sub-directories is not known. I want to put all the *.log files into the ...
-1
votes
2answers
85 views

Is There any unix command that does not make any system call while executing

I have been wondering if there is any unix command that does not make any system call. For example if we take into instance ls it also uses a lot of system calls, like open, read, write. We use ...
0
votes
2answers
30 views

Breaking up a file into two parts based on a particular line [duplicate]

I need to breakup a file into two separate files based on a particular line for example: . . sc_outfifo 0.000E+00 0.000E+00 0.000E+00 0.000E+00 1.586E-02 1.586E-02 1.586E-02 Fub_Level_DACGE(%) ...
0
votes
4answers
74 views

How can I test for the .RAW file extension?

I'm trying to set up an sh script that will run every 30 minutes. During each run, I want to check a directory for the presence of at least one .RAW file. Upon finding that file extension, I will have ...
1
vote
4answers
83 views

Last Working Day of the Month

#!/bin/bash #!/usr/local/bin #!/usr/sbin #!/usr/bin # Script to Check last working Day of the Month echo " Enter Month and Year :" read mon year cal $mon $year| egrep "28|29|30|31"|awk 'BEGIN { ...
0
votes
1answer
20 views

not getting variable's values inside the isql command

Below I am trying to automate the Sybase reporting job but unable to get the variable value as sp_helpdb proc's parameter. Kindly assist me to get out of this. #!/bin/sh . ./SYBASE.sh dblist=`isql ...
9
votes
3answers
293 views

Define variables with a variable name

What's wrong with this script? I'm trying to define A1=1, B1=1, C1=1 LIST="A B C" for x in $LIST do "$x"1=1 done and the result is: ./x.: line 7: A1=1: command not found ./x.: line 7: B1=1: ...
2
votes
0answers
21 views

When would you use $* instead of $@ in Bourne shells? [duplicate]

In Bourne shell and its offshoots like Bash, I believe the only difference between $* and $@ is that $@ expands in double quotes so that each argument ends up as a single word even if it contained ...
2
votes
2answers
43 views

automating CentOS 7 configuration using shell scripts

I notice I spend a lot of time using tutorials to manually configure a CentOS 7 server. How can I convert the manual steps from a tutorial into an automated shell script that can be used to configure ...
0
votes
0answers
33 views

telnet command with custom timeout duration

I'm trying to execute telnet command and getting the out put on shell script. But when the port not open or the ip not exist. The command take too much time to give the response. Will it be possible ...
1
vote
2answers
40 views

(Bash) kill process according to the memory used

i make this script to close a process, but i can't compare a output awk (var1) with a integer. the problem is casting in bash? #!/bin/bash var1= free -m |awk 'NR == 2'| awk '{print $3}' var2= ps ...
4
votes
3answers
82 views

How to use call-by-reference on an argument in a bash function

I am trying to pass a "var name" to a function, have the function transform the value the variable with such "var name" contains and then be able to reference the transformed object by its original ...
3
votes
2answers
33 views

Function with many arguments but only one switch

I am effectively making a recycling bin via some scripts I made. The first script is pretty much an alternative to the rm command (instead of actually deleting a file, it moves it to a deleted ...
6
votes
2answers
76 views

Notification Listener Behaving Strangely when Backgrounded

I've been struggling to get my IRC-Bouncer/Notification Script working. This is meant to be a script which will automatically login to a remote machine, attach to a screen session (or start one if ...
2
votes
2answers
67 views

Extract multiple instances of text between two words inclusive of starting word but exclusive of ending word

A PDB file contains numerous paragraphs of conformations of a protein. Each conformation starts with the keyword ATOM and ends with keyword END. I am trying to read the file in bash such that I ...
-2
votes
1answer
25 views

Shell script curl limit the try time for page not found

I found following code to check web url. if curl --output /dev/null --silent --head --fail "$url"; then echo "URL exists: $url" else echo "URL does not exist: $url" fi Here if the page not ...
0
votes
1answer
41 views

Shell script for logrotating

I want to create a shell script for logrotating. following are my requirement. want to archive the log files to a particular directory lets(/usr/local/jboss-5.10..GA/server/archive/log) older than ...
2
votes
1answer
57 views

Huge delay in script response when using SFTP with expect

I am using a script to call SFTP service to fetch some logs from the remote server. This works fine in normal scenario but, i have noticed a very long delay of around 30 minutes or more in some of the ...
5
votes
3answers
588 views

For loop formatting

I am having trouble formatting nested for loops for long strings of input: I am currently using the below nested for loops to name output files from a separate program that I have omitted: ...
3
votes
2answers
132 views

Subtract floating numbers in shell script

I'm trying to do some calculation in shell script with CPU usage. Which return floating point number. But when I subtract this number I'm getting error. See the following code and error. Code ...
1
vote
3answers
97 views

change of date format in awk command

I have a file mdn.txt with following sample record. mdn.txt: 123456,2711448,1,20150214092425,20150714092425,120,20150814163821,,123,,,123,20150214092425,,123,,,123,20150214092425,,123,Y Now I want ...
0
votes
2answers
42 views

Monitor a logfile and execute different commands depending on different conditions

I have a logfile which I want to monitor and depending on which condition is met, different commands should be executed. I found a solution that comes close to this here. Unfortunately it doesn't ...
0
votes
2answers
39 views

Search the value from a dynamic file and pass to a variable in HTML [closed]

I have the following file below with the format and I want to pass the value to HTML BE64533-A0E1-4F98-A91F-02C1D0 column=ABC_Received:ABC_Structure_Type, timestamp=1439978656596, **value=ASCII** ...
3
votes
1answer
186 views

Shell script error (: not found [No such file or directory]) [duplicate]

I'm using following script on linux server. And which is giving: : not found [No such file or directory] This is the script: # ------------------------------------------------------------------ # ...
2
votes
1answer
61 views

n-factor SSH authentication for CentOS 7

How can I enable (and require) n-factor authentication for all SSH connections to a CentOS 7 server? I have read about Google Authenticator, which provides two factor authentication. But that is ...
1
vote
2answers
49 views

How to subtract lines, in reverse, only if greater than previous line

I am working on a shell script that will read the lines of a file, in reverse. I need it to subtract the previous line from the latter, but only if the latter is larger. If it's smaller, then I just ...
1
vote
1answer
45 views

How to use sed to replace keys in a file using a regex?

I would like to modify a file to replace keys, suppose these keys are in the file as: 42NM 52NM 23NO XNNM I would like to replace anything with NM, with the word "Okay". 1 #!bin/bash/ 2 3 if [ ...
-3
votes
1answer
46 views

bash error: Missing '))' [closed]

#!/bin/sh echo "welcome to salary calculator" echo "Enter basic salary" read basic dp=$(( basic / 2 )) da=$((( basic + dp ) * 35) / 100) hra=$((( basic + dp ) * 8 )/ 100) ma=$((( basic + dp ) * 8 ) / ...
1
vote
1answer
42 views

printing in awk

I have a file number.txt with following record. Number.txt: 123456,2711448,1,14-Feb-15 09:24:25,14-Jul-15 09:24:25,120,20150814163821,13-Aug-15 09:24:25,,,12-Sep-15 09:24:25,,,12-Oct-15 ...
1
vote
2answers
61 views

Extract one file from multiple zip files

I have a folder tree which contains multiple .zip folders (approx 600) each containing four files. I wish to extract just one file from each folder and copy it out to a separate folder. To complicate ...
0
votes
3answers
62 views

find command behaviour inside for loop

I have following part of code inside bash script. for dir in $(find /etc/aaa -type d -maxdepth 1) do #my code done #my code if /etc/aaa directory is not present then i want to exit script with ...
2
votes
3answers
64 views

Grab the last executed command from history as a string and store in variable in bash

I'm trying to grab the last executed command, with options, and store it as a string to be written to a file. I've tried using fc but that can only give me the next to last command (for me anyways) ...
1
vote
3answers
58 views

Process text file - Extract data starting with number

I have a list of contact information I need to process in .txt format seperated by , . We only want to keep SIC codes that start with 65 which is real estate. The command should only check for the ...