Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [scripting]

A script is a sequence of commands or instructions that are executed by an interpreter program rather than compiled into a standalone executable program.

0
votes
0answers
7 views

i3lock called by the i3-nagbar starts in the background

I am trying to set up a lock script with the i3⁻nagbar command. The current code i have: i3-nagbar -b "lock" "i3lock" -b "shutdown" "shutdown -h 0" And while the shutdown button works, the lock ...
0
votes
0answers
48 views

Strange counting problem of variable in bash script

I have the following bash script which works fine until I get to number 9 (/dev/sdj) where it does not produce the expected output. hdd1="$(sudo fdisk -l | grep "Disk /dev/sd" | awk '{print$2}' | sed ...
0
votes
1answer
24 views

Problem with while function in AWK script

I have a pretty ugly looking script that I use to process evaluation files from simulations, it looks horrible and no I am not a coder, though it usually works, however it is currently not. Just to ...
1
vote
2answers
35 views

Bash script is breaking after Continue statement

Here I'm trying to ssh to multiple servers remotely and check whether any processes running on those servers and wait until the process to get finished. while read ip name do process=alive while [...
0
votes
0answers
5 views

Launch Openbox actions through script or cli

I was wondering if it is possible to run openbox actions, like the ones that can be found on rc.xml like MoveResizeTo , through a console command so I can launch it from terminal or inside a bash ...
0
votes
0answers
14 views

arch linux udev script trigger

I am looking for some support with an issue I have come across today. What I am trying to do: I am trying to use udev rules to trigger a python script which does multiple things including making a ...
1
vote
0answers
24 views

Run bash script as application, such as a Desktop icon does [duplicate]

What I can I do to execute bash script as application like open the "Desktop icon". Any idea for where can I start?
0
votes
2answers
48 views

Single text file: Compare the first n characters of each line and the next. If they are equal print the longer of the two in output file

I am using the Ubuntu bash. My file contains paths from a filesystem. E.g. C:\users\username\subfolder\thisismyfile.txt C:\users\username\subfolder\thisismyfileplusadate.txt C:\users\username\...
0
votes
2answers
25 views

Returning wrong results in perl script [duplicate]

I am running this command on linux shell it works smoothly sed -i 's/\[-.*-]//g' error .txt What it does is it removes patterns like [-any text-] along with the brackets and - sign. but when I try ...
0
votes
3answers
78 views

perl regex - How to match foobar that does not begin with (\s*//\s*)

Basically I want to find foobar on uncommented lines like: // foobar # do not match me foobar # match me otherfoobar # do not match me To match the commented lines I use this: ^(\s*//...
0
votes
2answers
35 views

Group Together Items By Consecutive Number

I have a series of files that look like the below, I need to group them into "consecutive groups", each line starts with a number, the file should be read from top to bottom, and if the next line ...
1
vote
0answers
33 views

What is difference between `` and $() for command-substitution in bash scripting? [duplicate]

I'm new to Linux and StackExchange. My English is pretty bad, and I'm sorry for mistakes. What is the differences between `` and $()? Does it matter what to use and when? I'll be grateful for ...
1
vote
1answer
35 views

getopts in function that is called more than once in a script, getopts doesn't detect any opts after 1st function call [duplicate]

I have read the getopts man page and am still not sure about this use case. getopts is not detecting any available options the second time a function is called in the same script. As you can see ...
0
votes
0answers
28 views

Debian 9 stretch - How to prompt user from rc.local script and echo in current terminal

I need to create an easy to go Debian VM for new developers on my team. I run a script on boot with rc.local. This is a small test script : #!/bin/bash exec < /dev/tty1 # Checking if user ...
0
votes
1answer
37 views

Getting Error with system() in perl

' Number found where operator expected at ./scripttemp.perl line 5, near ""sed -i -r "4" (Missing operator before 4?) String found where operator expected at ./scripttemp.perl line 5, near "}" ...
-2
votes
0answers
30 views

Using Grep in perl script [on hold]

I want to execute the grep command inside my perl script. this is my command : grep -nr "{+" error.txt > error1.txt I want to find this character in file error.txt and want to print the line ...
1
vote
1answer
65 views

$! not being set to the PID of a > >(…) process substitution used with an external command

Bash 4.4.19(1)-release I have below a simple script which is the basis for a logging app. For various reasons I had to use process substitution. The runner is the heart of the app and since ...
1
vote
1answer
40 views

Is it possible for a function to distinguish if it is run like this? “${@}”

This is my simplified script. I am wondering if the proc() can know if it is run directly or through the runner. #!/bin/bash runner () { "${@}" } proc() { eval 'version=$(echo "SUCCESS: ****...
0
votes
1answer
31 views

Extracting two pieces of data from one file and inserting them into two different places of a different file

I have a file named parse.txt that contains the following 2 lines: 60 Moderate I'm hoping to have a command in a bash script that will insert the 60 into line 7, column 17 of a new final.txt file, ...
0
votes
2answers
35 views

I cannot get the PID for this “${@}” 1> >(2log) 2> >(2log2scr | tee >&2)

I searched a bit on how to do this, but I cannot find a solution. I am using process substitution cause of necessity. I want to wait for all the processing to finish before proceeding. How do I get ...
0
votes
3answers
24 views

Are there any “helper” scripts to assist with loading/overriding command arguments?

I have the following script sub.sh: #!/bin/sh . ./sub.conf echo $topic mosquitto_sub -u $user -P $password -h $server -t $topic And the associated settings file sub.conf: topic="#" #-...
1
vote
0answers
72 views

Shell script cannot find file [duplicate]

I am trying to install a gcc-arm version but run into trouble while trying to run the setup shell script. Following step 2 in the prerequisites I downloaded GNU ARM embedded toolchain v4.9-2015q3. ...
0
votes
0answers
28 views

What is the useful case of trapping shell script's EXIT? [closed]

Trapping a shell script exit can be demonstrated like this. #!/bin/bash trap "ls -al" EXIT count=1 while [ $count -le 3 ] do echo "This is $count" sleep 1 count=$[ $count + 1 ] done ls -al ...
0
votes
1answer
56 views

Process Substitution ECHOS undesirable 'shell prompt'. Can I disable it?

NOTE: This question has arisen due to asynchronous processing of 'Process Substitution'. The script responses were deceptive, causing many lost hours. A previously related post is here: cat in process ...
1
vote
2answers
31 views

Script to combine separate csv files

I have two separate files containing information on clients that I would like to merge into one. The first file contains global information, the second is for options. Basically, every client has an ...
0
votes
1answer
32 views

Linux unable to find and execute script, despite being in the correct directory [duplicate]

I have a basic start script for an application that I am trying to run. However, every time I execute it: ./start.sh It fails with this error: -ksh: ./start.sh: not found [No such file or ...
0
votes
1answer
62 views

Can I process command output just before sending it to a file (one liner)?

I have a command processing function that runs its arguments and outputs the results to a file. The outputs of those commands must now be PROCESSED just before going to the file. I have only one ...
-4
votes
0answers
34 views

Script to add fuction header to all api's in cpp file [closed]

How to add function header template like this - **************************************************************** Function Name : XXXXXXXXXXXXXXX(setNameOfStdent to be auto filled) Description : ...
0
votes
2answers
28 views

Finding a file by alphabetical order

Using bash, I need to be able to find a file in a specific position when listed alphabetically. For example, if I had the files a, b, c, d, e in a directory, and I wanted to find the third file, I ...
0
votes
0answers
24 views

run script continuously and check for error

I have written below script and it reads the file and when ever there is any 400* or 500* word it will give me error message, and now I want to add two more functionality to my script. I added the ...
0
votes
2answers
61 views

grep files with pattern A but exclude files with pattern B

I want to grep files which include pattern A (iwant) but I want to exclude files which contain pattern B (idontwant). Example: read -p "...what are you looking for: " iwant read -p "...what should ...
0
votes
1answer
22 views

Trying to parse a string in BASH for [ - _ ]

I have a BASH script that allows a user to specify a jobname. Right now we except everything. We feed this jobname into another executable that can only accept the following formats: job_name, ...
-1
votes
1answer
28 views

simple systemd service for execution of shell script

Im trying to start a simple .sh file and it says Failed at step EXEC spawning /etc/start.sh: No such file or directory Content of the gnome.service [Unit] Description=Description for sample script ...
0
votes
1answer
17 views

How to extract Oracle DML (insert,update) queries from a dump file?

Example: $cat data.txt SCN THREAD OPERATION ID OBJECT ID OBJECT NAME REPLICATE OPERATION SQL ------------- ------- ------...
1
vote
2answers
22 views

How can i check if my host command in script got a valid ip

Suppose we only have 1 parameter host $1 How can I check if the above command will give me an answer or: Host $1 not found (NXDOMAIN) and instead of showing an error not found, I would like to ...
1
vote
1answer
23 views

How to count how many times each line appears in a file

I have something like this teithe.gr List item deitel.com parinux.org cs.vt.labs.edu cs.may.ie csse.monash.edu.au amazon.com amazon.com teithe.gr teithe.gr I just want to know how can I count each ...
0
votes
2answers
36 views

I have a text file with with 3 columns separated with : how to sort the second column by the last 2 digits of column 2?

This is an example of the text file: 195.92.211.47:21029:400 195.92.211.48:21023:400 How can I sort the lines of the file by second column's last 2 digits? The second column is always five digits.
0
votes
2answers
29 views

Using grep and logical operators for pattern matching within shell script

Im trying to develop a script that finds a specific pattern in the output of the dig command running against a list of domains. To do this I'm using grep but having difficulty implementing this using ...
2
votes
1answer
44 views

Redirect echo in trap function back to stdout

I'm currently having an issue getting echo statements in my trap function to be printed to stdout. I'm redirecting all output (error and stdout) to a log file from a command that I run. But if it hits ...
0
votes
1answer
61 views

Correcting a shell script

I have got a section of shell script which was working earlier but now it is giving some different results: MSG= while true do themenu getchar = case $answer in 1) ...
0
votes
1answer
31 views

Bash script for grepping string and placing them into array

I'm looking way to make bash script that greps output of command and place strings into array and be able to randomly select 1 string from the array for example every minute and place it as variable, ...
1
vote
0answers
14 views

stderr changes behavior of python's Popen when closing the script [migrated]

I was using this script on python2 to launch an application and then immediately exit the python script without waiting for the child process to end. This was my code: kwargs = {} if platform.system()...
1
vote
2answers
66 views

selective deletion of lines between two patterns

I have a file which contains following content, Hello world Unix!! Its bright world Current time is HH:mm:ss Next action plan is item #3 End of task. Thank you. Hello world Linux!! All actions ...
2
votes
1answer
36 views

Bash script to count number of executions instances does not work

I am writing a script that detects if there is any instance of it already running on my Linux machine and shows on screen the number of instances. The content of the "detect_itself.sh" script is: #!/...
0
votes
1answer
41 views

Execute a remote bash script locally

I've seen that it's possible to run scripts stored locally on a remote server eg.: run a command: ssh USER@HOST 'COMMAND' run a script ssh root@192.168.1.1 'bash -s' < script.sh What about ...
0
votes
2answers
40 views

Strip the output of the ping command?

I would like to as if it is possible to strip the result of the 'ping' command form the last three lines which are always: --- domain.com ping statistics --- 3 packets transmitted, 3 packets received,...
0
votes
2answers
74 views

BASH Tools for conf file manipulation? [closed]

I am wondering if there are any tools for use in bash scripts that can easily allow you to manipulate (add, remove, update) directives inside conf files? e.g. fail2ban.conf has grouped directives, ...
0
votes
2answers
43 views

Progress bar to display progress based on number of files found/completed in for loop?

Is there a progress bar that can show visually completed progress based on the number of detected files found and completed in a for loop like the one below? mkdir -p hflip; for i in *.mp4; do ffmpeg ...
-2
votes
0answers
32 views

How to prompt all questions in shell script at very beginning?

Are there ways of running a bash shell script and quizzing the user for yes/no/multiple choice type questions in the very beginning of the script, but then applying the changes later? Meaning execute ...
-1
votes
1answer
31 views

Why is this bash script read line code giving me errors? [closed]

Why is this bash script read line code giving me errors? read -p "Does this require cropping? (y/n)? " answer case ${answer:0:1} in y|Y ) mkdir cropped; for i in *.mp4; do ffmpeg -i "$i" -filter:...