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

learn more… | top users | synonyms (2)

0
votes
1answer
29 views

Bash/OSX script to run commands in 2 Terminal/iTerm tabs?

To run my node server proxy and then my project in Gulp Browsersync, every time i need to run node server in one tab, open a tab in the same directory and run Gulp. I'm not sure if the second tab is ...
1
vote
2answers
37 views

How do I update the dates (by 30 days) in the files going to that specific location in unix?

How do I update the dates (by 30 days) in the files going to that specific location in unix? Can awk or sed help ? File format is as below - Thomson: xyz Format: 1 Character_set: ASCII8 File_type: ...
0
votes
2answers
50 views

Regular expression for excluding data within a certain range

I want to remove all the IP addresses which are of the format 10.20.30.* and whose last 3 digits fall in the range 0 to 200 and move all the remaining IPs to a new file. I've put the IP list to be ...
-1
votes
1answer
41 views

permission denied on running script despite +x

Script is on exec partition (under /home/~~~ ) and have +x flag (-rwxr-xr-x ). executable on bash shell (not with script) but not on script. script is quite simple. #!/bin/bash data=cat ...
1
vote
1answer
39 views

How to pass a path to a file through a call to perl from bash?

This is a more advanced version of a previous question (How to pass arguments to perl when trying to change a line?) I made. This time I am trying to pass a path, but evertything seems that the the ...
2
votes
2answers
99 views

Script to determine if files are Images

I would like to create a shell script that will check to make sure all files in a directory are image files. We recently had an issue where a hacker was able to generate a file in a directory and ...
0
votes
1answer
30 views

how to stop at a specific point in a list

I created a shell script called blossom() because my girlfriend's dog Blossom poops and pees on the floor all the time. blossom() { echo poops and pees on floor all the time } Because I am such ...
0
votes
4answers
48 views

How to classify these lines in this ASCII file

The ASCII file I have is this: a 1 2 3 1223 b 1 2 3 5 3344 1223 c 1 2 34 a 4 5 c 123 How do I collect the lines below a,b,c respectively? Q: What would I do to get the lines below? a 1 2 3 1223 4 ...
2
votes
2answers
30 views

How to Save variables in a script that can be shared between two runs of awk against the same input file in the script? [closed]

I have a log file, whose formatting is very consistent and which I control. It produces pipe-delimited fields of constant length. Two fields are relevant to the filtering process I wish to create, ...
3
votes
3answers
138 views

Splitting a sequence into fixed width

I have a file like this which is a two-column tab-separated file. CTGCAGTTTCCCCAAATGTGGGAAACTTGACTGTATAATTTGTGGCAGTGGTA a1 GATTTCCCCAAATGTGGGAAACTCACTCGGCAGGCGTTGATA a2 I want to get an output ...
0
votes
2answers
34 views

Run script and not lose access to prompt / terminal

I am running jmeter by launching the .sh script, once I do that I cannot start using the prompt again unless I ctrl-z, ctrl-c, or the script ends in some other way. How can I launch that script and ...
2
votes
2answers
51 views

Create array in bash with variables as array name

I'm not sure if this has been answered, I've looked and haven't found anything that looks like what I'm trying to do. I have a number of shell scripts that are capable of running against a ksh or ...
1
vote
1answer
61 views

Run shell script from crontab after server stop/start/restart

I want to schedule a shell script in crontab that runs whenever server restarts. It should also run when someone starts the server after it stops abruptly or crashes. How to do so in crontab? Any ...
-3
votes
1answer
55 views

Using AWK to define variables in a shell

I've got a live MQTT stream being filtered out and dumped into a CSV file. I use the fourth parameter ($4) and fifth parameter ($5) in the CSV file to locate the information I want. I give this ...
0
votes
0answers
26 views

Error while setting up environment for running swift

I am getting the following error when running the script remakerings # remakerings Traceback (most recent call last): File "/usr/local/bin/swift-ring-builder", line 5, in <module> ...
0
votes
2answers
48 views

Not getting grep with a variable

I am assigning a variable to echo command which generates a random number. For eg: n=$(echo $(( (RANDOM%6) +1)). I have to grep this variable in /etc/passwd. So, my syntax reads like: n=$(echo $(( ...
3
votes
5answers
283 views

How do I loop over output from shuf?

If I do gshuf -e $(seq 1 10) in bash it will print the numbers 1 thru 10 in random order. But if I do: a=$(shuf -e $(seq 1 10)) for i in "${a[@]}" do echo $i echo "next" done It prints ...
0
votes
0answers
16 views

How to backup current chkconfig configurations

How to backup current chkconfig configurations chkconfig --list list the current services configurations, and when (run level) a service set to start. I need to backup the configurations and check ...
0
votes
1answer
44 views

What is wrong with my init.d script [Segmentation fault]

I currently filter out data from a MQTT live stream. I then dump this datum into a csv file named mqtt.csv and the dumping process is done by executor_start_up_job.txt which is written in BASH. I ...
3
votes
3answers
42 views

How to change directory from script without calling the script with . ./script, or exit the script when calling . ./script.sh

I have a bash script which moves the user calling the script to new working directory. If I call the script with . ./script.sh cd works, and user gets moved to new directory, but the problem is that ...
0
votes
2answers
48 views

linux curl POST request not working

I am trying to make a POST request using curl to retrieve exam results from the page : result odd .... I am using the following syntax but various errors are showing up (like content has moved ...
0
votes
0answers
52 views

'cp:cannot access file' error in script?

This is the code: #!/bin/bash $REPORT_PATH='/data/operational/logs' cp "$(`ls -t | head -1`)" "$REPORT_PATH/new_file" This gives error 'cp:cannot access pda_param'. pda_param file is o/p of ls ...
0
votes
1answer
69 views

Shell script printing blank $USER variable when executed by Smartd

I have created a script that smartd daemon (smartmontools) executes as per command below. DEVICESCAN -a -m email -M test -M exec /usr/share/smartmontools/my-script -n stand... Smartd appears to be ...
3
votes
1answer
86 views

Bash scripting to scan files for words and create report

Ok yes this is a homework assignment BUT I am NOT looking to have the answers given to me. The scenario is that I need a script that searches all my users home directories for bad words. I need the ...
1
vote
2answers
81 views

execute a script with some permission

In myscript I have a line that does this : chmod 660 somefile_given_as_argument_to_myscript I gave the members of a group the right to exectute the script. (chmod 770 myscript) but when they ...
1
vote
1answer
29 views

How to Subscribe a Bash Script as a MQTT Client

From my understanding: Client can be any device as long as it has an MQTT library running on it, from a microcontroller to a server, but must be connected to an MQTT broker over any network Broker ...
0
votes
1answer
35 views

How to send multiple email results to my email in single message

I would like the email results to be delivered to my email in a single message. Can you please tell me how can I do it. Here is a copy of my script below. All 3 email matters should come in single ...
0
votes
1answer
16 views

I'm trying to deploy with git to a semi-managed vps, need to write a script to change owners

I'm trying to deploy my sites on my company's semi-managed vps server using this tutorial: https://www.digitalocean.com/community/tutorials/how-to-set-up-automatic-deployment-with-git-with-a-vps It ...
0
votes
1answer
38 views

Parse header in a file and based on the header replace a value in the file

I have a problem I need help with. I'm not very experienced with awk, but it seems to be a good tool for this job. I have the following file Field1|Field2|Field3|Field4|Field5 a|b|c|d|e 1|2|3|4|5 ...
-8
votes
0answers
40 views

didn't et answer so posting it again---Unix script-help needed [duplicate]

I want to make a script in unix .I have 2 files with same structure with pipe as a delimiter. Now first i want to check if column1(eid)-->file1 is present in column1(eid)-->file2,if so then it will ...
3
votes
1answer
21 views

Pipe command output to Yad and also log the output to a logfile

Need to have the process of command typically an update to be shown using yad and at the same time log all the output to a given log file set up. This is what I have apt-get update | yad ...
0
votes
0answers
108 views

Bash script to create montages of images with G'Mic

I need a bash script which will run through a folder of 100s of jpegs and create montages of every 30 images and output the montages with distinct file names. The G'Mic command to create a montage ...
1
vote
1answer
56 views

shell script to auto kill processes matching certain criteria

when running top it shows a couple of processes got nearly 100% cpu usage of the command 'perl' PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 21287 simon 15 0 4141 ...
-1
votes
3answers
46 views

Counting files commands in a loop

How can I use ls *.txt | wc as a separate variable so I can use it in a loop afterwards? That is count.files=$(ls *.txt | wc) ... if count.files -ne 2000; then echo "message" fi I have tried it ...
3
votes
2answers
44 views

How to deal with utilities with same name but behave differently between Unix variants?

For some reason, I chose Macbook as my computer to managing remote Linux servers. Sometimes I will encounter troubles with those utilities which have the same name but behave differently between ...
-3
votes
0answers
20 views

Want to write a unix script to compare two files with multiple columns [duplicate]

Need to make a script in unix .I have 2 files with same structure with pipe as a delimiter. Now first i want to check if column1(eid)-->file1 is present in column1(eid)-->file2,if so then it will ...
1
vote
3answers
39 views

How to can I make Filename Sequencing with the help of Loops

my intention is to keep the code as simple as possible.Here there are 5 files namely A_1.CSV, A_2.CSV, A_3.CSV, A_4.CSV, A_5.CSV The below code retrieves the first row in a CSV file. Code : ...
0
votes
2answers
43 views

Is `grep -P` (Perl/Python regex) portable on most linux distributions

I prefer (Perl/Python Compatible Regular Expressions) regular expressions. man grep: ...., but only work if pcre is available in the system Is this supported on the most common linux ...
1
vote
2answers
73 views

Creating multiple input files by using sed in a for loop

I am a newbie and wasted a lot of time on this so any help is greatly appreciated. Suppose I have a simple Mathematica script file named "a.m" which contains the parameter 'a' with no assigned value: ...
1
vote
3answers
48 views

How to grep over a variable [duplicate]

I have a scenario like VAR = `Some command brings the file path name and assigns it to VAR` For example VAR can have value like /root/user/samp.txt I want to grep command like grep HI $VAR ...
1
vote
1answer
43 views

Processing output from an sqlite db into a ksh array with spaces

I am querying an SQLite3 database like so: input=$(-separator "," "SELECT field1,field2,field3 FROM table1") and get this result: Red,Yellow is a color,Blue I need to insert this into an array, ...
1
vote
1answer
57 views

remove lines where a field's value is less than or equal to 3 - sed or awk?

I need to remove every line that has a value of 2 or less in the 8th field (column). My data looks like this: 12-31 Airport 189 379 41 49.70946503 -124.91377258 2 2880 30.8 01-01 ...
0
votes
2answers
115 views

Debian autossh boot script not working properly

I wrote the start script at the bottom of this question to try to get one of my devices to automatically create several remote forwarded ports with my VPS upon boot. (I've stripped the LSB tags to ...
2
votes
3answers
75 views

Copy files to a destination folder only if the files already exist. but the source files have a different file extension

Copy files to a destination folder only if the files already exist. but the source files have a different file extension. i.e I have a backup of some files with ".desktop.in" extension and I want to ...
4
votes
2answers
119 views

Running a script during booting/startup; init.d vs cron @reboot

I am currently trying to understand the difference between init.d and cron @reboot for running a script at startup/booting of the system. The use of @reboot (this method was mentioned in this forum ...
1
vote
1answer
32 views

Specify the type of field to modify in a file

I have a list of clients, "code", "name", "location", "etc" and I want to make a function that asks the employee to give the client's code and then the field he/she wants to change. For example, ...
1
vote
0answers
38 views

Text User Interface

I have been working on a shell script, and was wondering if I can put up a text user interface for the shell script. After some searching, I see few people suggest using "ncurses/curses". However the ...
1
vote
1answer
91 views

Shell script `rm -r`: Redirect write-protected prompt and answer “n”

I have a few lines in a shell script whose function is to iterate through directories, match some names, and delete them. Some areas of the file system are write protected and I would like to leave ...
2
votes
3answers
67 views

Calculate date difference between Last modified date of a file and NOW using shell script

I am trying to calculate the time elapsed since the log file was last updated. I guess following commands will be used lastUpdate=$(date -r myLogFile.log) now=$(date) How can I subtract them and ...
3
votes
5answers
173 views

Pick the latest file based upon the sequence number given in the file name

I have a requirement, I have few files in a directory, I need to pick the oldest one for processing. For Exp: I have below files in /tmp directory: Sample_0000237826-001_xyz.dat ...