Questions tagged [shell-script]

A shell script is a script written for the shell, or command line interpreter, of an operating system.

Filter by
Sorted by
Tagged with
-1
votes
2answers
58 views

Insert a character after match with bash

I'm writing a bash script. I need to introduce a colon after the first occurrence of a character. /c/Users/ertwr/org/readme.html and in order to open them with the native Windows browser the need a ...
1
vote
1answer
29 views

Simple if/elif/else bash program with READ

The following code always ends up in the else part - also if I enter "peter" or "root". I do not get a syntax error. What am I doing wrong? #!/bin/bash # Hello World bash script echo "What is your ...
1
vote
1answer
24 views

How to add a text/string in-between two matching texts using awk/sed

In Below file. nsswitch.conf hosts: files mdns4_minimal [NOTFOUND=return] dns myhostname networks: files protocols: db files services: db files sss ethers: db files ...
0
votes
1answer
33 views

Recursively list all files and subdirectories with modified timestamp

In a Unix Shell you can use the following to print a list of all files and subfolders recursively: cd some/path/to/folder du -a and you can list file information (such as permissions and timestamps) ...
0
votes
0answers
39 views

How to get access of all the parameters a user used to call a shell script? Or forbid the use of * as a valid parameter?

I have a shell script that will be a such of a header to be imported by others scripts Its main goal is forbid the user of "*" and "?" as parameters. I've already tried: 1) To get access to the ...
-1
votes
1answer
22 views

Extract comma separated values from variable and store them in array in shell script

I have a shell script and a variable that contains numbers separated by comma. The variable would e.g. look like this: 14,7,45,12,13 Now I would like to extract all of those numbers without the ...
-1
votes
1answer
26 views

Rename files in specific order [closed]

I'd like to have a script that renames files (add numbers in front of it) depending in which folder they are. So I have following scenario: AAAMap AABMap AADMap AAEMap AAA.map AAB.map AAD.map AAE....
0
votes
0answers
15 views

GIT Auto Versioning on DEV branch

We are using centralized Gitlab server. I need to enable auto versioning on dev branch of centralized gitlab server, So when ever any one push the code on dev branch their tag version should be ...
1
vote
1answer
26 views

awk + print lines only if second field match hours:min:sec

log file is like this 34.3.23.58 07:20:01 AM all 0.02 0.00 0.02 0.00 0.00 99.97 34.3.23.58 07:30:01 AM all 0.02 ...
2
votes
1answer
41 views

Embed a Windows shared clickable path in the mail

I want to send a mail by embedding a clickable link to a shared windows NAS path. I checked solutions where we can use something like "<html><body><a href= But I am not sure how to put ...
0
votes
1answer
40 views

Condition in bash script

I want get [4 file name string] from user and pass these parameters to bash script. script should copy files in user home directory. FYI: each file might be exist or not, might be one of them exist ...
0
votes
1answer
27 views

How to match specific strings together from two lists?

I'm trying to match specific individual strings together. For example, I'd like the following to be paired: file1 and 123.jpg file2 and 432.jpg file3 and 345.jpg Currently, I'm using the following ...
0
votes
0answers
10 views

Predefine pgAdmin setup.py email and password in shell script

I would like to write a shell script for automatized pgAdmin install. This below command asking for email and (twice for) password: /usr/lib/python2.7/site-packages/pgadmin4-web/setup.py I tried to ...
0
votes
0answers
14 views

Flat File Validation

there is a requirement to do validate on Flat files using Shell Scripting. Suppose we have two flat files ( F1, F2). Validation Row count between F1 and F2 a) Write it in a file with results of ...
0
votes
1answer
27 views

how i find the list of files which should contain both string patterns are present in a given directory

i have active directory which contain multiple subdirectories.i want to find the list of files which should contains the string patterns as "String1" and "String2" respectively
0
votes
1answer
75 views

How can a file be loaded and processed from the Terminal in Linux?

Assume you have a file with integers, one per line. Your job is to take that file as an argument and print the maximum and minimum values in the file. How can that file be loaded and processed from ...
0
votes
0answers
43 views

How to run multiple script in Shell Script?

I have three scripts in one directory (test.sh , build.sh, and agent.sh) I created a script in the same directory to run all those scripts, but my codes just doesn't seems right for me. My script ...
0
votes
1answer
90 views

Batch Maven build breaking cmd.exe?

I had a Windows .bat file with a script for compilation of a project I'm working on. The last command is a maven build. Since it takes a while to finish, I wanted to be notified when it does. I ...
0
votes
1answer
97 views

How to change my working directory using “Execute shell script on remote host using ssh” in Jenkins?

I put these commands inside the command field just to check if I am able to change my working directory.. pwd cd /apps/working/agent/working_agent/ (Directory path to run my script) pwd However ...
0
votes
0answers
14 views

Batch unzip shell script

I am currently using this script to extract different types of zip folder structures and has been running great. Recently, I have noticed one zip file that the script doesn't cover. - myfile.zip -...
0
votes
1answer
55 views

cp: Copy multiple files to multiple destinations from index

I have a directory containing multiple configuration files that I'd like to copy to disparate parts of my home directory. In order to give more control over where the files go and which are copied, I ...
0
votes
1answer
99 views

Assign variable value base on another variable that doesn't yet exist in Bash

For a BASH script, I need to assign the value of another variable that does not yet exist to a variable earlier in a script. I do not however need to call upon the earlier variable until after the ...
0
votes
0answers
12 views

Script for making requests to ORS and to read the data from the psql request

I've got a postgresql request which is output for me the coordinates and the distance between this coordinates. I need to make a script which is gotta requesting coordinates one by one to local ...
0
votes
0answers
26 views

Detect keys already pressed at the time script starts

My script that runs in a Linux desktop environment (XFCE, Gnome) is registered to run on a global hot key event (e.g. Super+D). That script pastes something from the primary clipboard (I use xclip + ...
0
votes
1answer
30 views

How to rename parts of a file name recursively from a list?

I've got this script for file in /folder1/folder2/*; do mv "${file}" "${file//\[Free]/}"; done And I'd like for it to: Search all subfolders in folder1 and folder 2. Pull from a list ...
0
votes
2answers
111 views

shasum of a directory in macos

I'm writing a shell script that uses the shasum to check if the contents of a directory have changed. On Linux and FreeBSD, the shasum have the same behavior when I do shasum <directory> ...
0
votes
0answers
25 views

how to run the bash script interactively via ansible playbook

I can run the script with the command line argument on the linux server it works fine. for e.g.: ./install.sh -n -I the above command is able to install the script on the server. When I am trying ...
1
vote
1answer
73 views

How can I stop an inlined background process when my script stops?

In a shell script, I do the following: #!/bin/sh while true; do ssh -o ExitOnForwardFailure=yes -L 8080:localhost:80 -N server; sleep 1; done & ... rest of the script, which uses the tunnel as ...
0
votes
1answer
123 views

Is it possible to execute a while loop in the background?

I am creating a shell script and want to execute a certain while loop in the background. Normally, I would create a new watch.sh file containing: while true; do ...; done Then, in my main shell ...
0
votes
1answer
21 views

FFMPEG Split Mp3 using CSV in Shell, parsing doesn't seem to work

Task: Split one mp3-files to several mp3-files, use a CSV-File with Starttime, Endtime, and Title. Errors: Skipped Parts, some parts with wrong naming, randomly accruing errors: Invalid duration ...
0
votes
1answer
58 views

Linux Bash scripting execute a terminal command on a list of filenames

I have a file with a list of filenames that I am attempting to use as input in a specific file download tool (sratools) but my script has an issue #!/bin/bash input="<path_to_directory>/...
1
vote
1answer
73 views

How to shorten a list of variable names in bash?

In a shell script, I have a list of variables that I've ordered as $a, $b, $c, etc. I'd like to print these variables without having to list all the variables. My current code is as follows: a=1 b=2 ...
1
vote
0answers
21 views

Cron Behavior in HP-UX

I am trying to monitor my server through a script which is run by cron in HP-UX environment. However, an if-else condition is not working correctly when run by cron. For example, if certain condition ...
1
vote
2answers
35 views

How to kill a pipeline once some output has occurred

I want to run this: ./configure | grep GNU but the configure script hangs after it has output the lines I'm grepping, waiting for user input (which I'm not going to provide here).  Is there a way I ...
0
votes
1answer
42 views

Can I simplify and negate this? ^(//|//\s+|\s+//|\s+//\s+)

Basically I want to match commented lines like: // foobar (this is a commented line) but I want to make sure I catch this line even if there is white space either side of the comment signature '//' ...
0
votes
1answer
63 views

Shell: How to create a user with the same password with another user?

Linux has a user, root. It has a password, unknown to the shell script. No human can input anything for the script. The script wants to create a user, user001, with the same password with root. ...
0
votes
0answers
22 views

Check if similar sentence repeated twice in a line

I want remove those line in which similar sentence repeated twice in same line for example: Total time [any text between brackets] Recieve Time [10.78.12] Total time [any text between brackets] ...
1
vote
0answers
67 views

How do I merge videos that have overlapping frames into a video without duplicate frames?

I've nvidia highlights that takes 3 minutes recordings when events happen. If two events happen sooner than 3 minutes then those recorded clips have overlapping frames. I want to take all the clips ...
0
votes
3answers
46 views

Temporarily disable files in macOs

Is there a convenient way to temporarily make files 'not found' to the OS (or more specifically, an App)? I was thinking an automator action that just adds '.DISABLED' to the filenames, but automator ...
0
votes
0answers
24 views

How to edit script to run on all files within directory?

How to make this script run on all video files within directory executed? #!/bin/bash # Fade OUT, TO BLACK: # length of the fade out fade_duration=2 # seconds if [[ ! $2 ]]; then cat<<...
0
votes
0answers
77 views

Continuously detect a change of chksum of files under folder with inotify-tools

I just installed inotify-tools. I would like to continuously detect change of chksum of files under folder /path Once a change was detect ( under /path ) then it will print echo “chksum of files ...
0
votes
0answers
19 views

kMDItemFSCreationDate is acting like modified date instead of creation date

I cobbled together a shell command that would reveal the newest file added to my system. open -R "$(mdfind -onlyin $HOME 'kMDItemFSCreationDate >= $time.now(-7000) && kMDItemContentType !=...
0
votes
0answers
10 views

how to fetch the mpeg stream from local URL/ COM port using shell commands in unix based(raspberry) system?

I am looking for a suggestion through which I can try fetching some mpeg stream at very low frame rates from the local IP/COM port and transport it whole into other system with the help of an ...
0
votes
0answers
55 views

Raspbian: bash script running fine in terminal window, but not when added to autostart

I use a script to start the google voice assistant on my rpi. This script runs fine when I run it from a terminal window, but when I try to run it via the LXDE autostartup nothing happens. It used to ...
0
votes
0answers
27 views

How to download only particular folder files of sub-folders from FTP site in command line in linux

I had tried using this command "wget -r ftp://ftptrace.ncbi.nlm.nih.gov/giab/ftp/data/AshkenazimTrio/HG004_NA24143_mother/NIST_HiSeq_HG004_Homogeneity14572558/HG004_HiSeq300x_fastq/...
0
votes
0answers
39 views

Configure time consuming Shell script execution before shutdown linux instance

I am looking for the solution to configure a shell script which will successfully execute when linux instance is shutdown. but there is a challenge, I required network to execute my shell script also ...
0
votes
0answers
18 views

sh(conf) script can not run php file

I am trying to run a php script within my fail2ban action file. When I disable selinux everything works fine, but when I enabled it again I get a constant error in my fail2ban log. php.conf (action) ...
0
votes
2answers
51 views

Run shell script even in sleep mode?

I want to create a script that logs the battery level and CPU load on a laptop, however I still want to log the battery level whilst in sleep mode. Is there any way to do this in Linux? OS: LM 18.04 ...
0
votes
0answers
61 views

Obexctl: Provide different result in terminal and script

I have created a script where I want to send file over bluetooth. For that I took "obexctl" utility. I can transfer file using obexctl utility over terminal. But when I'm trying to incorporate the ...
0
votes
0answers
11 views

PostgreSQL date-dependent operations

I want to add a function like trigger to my Postgre database. The problem is that this function should executes one time each day automatically and change values in specified table. Is it possible to ...