Skip to main content

Questions tagged [bash-scripting]

Bash scripting is making scripts in the Bash shell language.

Filter by
Sorted by
Tagged with
0 votes
1 answer
33 views

Restart autosys job after a fixed delay

I have a scenario where I have to retry run the failed autosys command job after 10 minutes. I have to retry rerunning it only twice. I cannot use n_retry attribute here because I need to wait for 10 ...
Priya's user avatar
  • 1
0 votes
1 answer
28 views

SOX do not want name files

Want to record a radio broadcast into separated files. receiver | sox -traw -r8k -es -b16 -c1 - -b16 -es -c1 -r48000 -t wav ~/myfolder/$(date +%H_%M_%S).wav silence 1 0.10 0.1% 1 1 0.1% : newfile : ...
Oleg M's user avatar
  • 3
0 votes
0 answers
49 views

bash sourced command silently fails under WSL2 vs direct execution from shell?

I have a Bash script which evaluates JSON file to set environment variables and creates a function The script works fine under native Ubuntu (22.04LTS), but when you run the same script under WSL2 (...
Gnudiff's user avatar
  • 189
0 votes
1 answer
40 views

Match a User That Starts With a Single Letter

I've been handed a script written by another and been asked to modify it according to their needs. There's one line that needs to be altered: if [ "$user" == "nobody" ] This ...
user2090974's user avatar
0 votes
0 answers
127 views

Separating audio m4b file based on a cue file

Separating audio m4b file based on a cue file How can I split an audio m4b into separate files using a cue file? Note: The m4b file has no chapters that's why I need to use the cue file to split it. I ...
Rick T's user avatar
  • 153
0 votes
3 answers
38 views

Why doesn't `bash` work with piped output, when the output is as expected?

I'm running the following command to alias an entire folder of scripts: ls | grep '\.sh$' | sed 's/\.sh$//' | awk '{print "alias "$1"=\"./"$0".sh\""}' | xargs -...
Maxime Franchot's user avatar
2 votes
1 answer
108 views

Execute self-extracting bash script (with binary data appended) w/o saving it first

I have a self-extracting bash script (binary data appended to the end) like this: #!/bin/bash export TMPDIR=$(mktemp -d) ARCHIVE_START_LINE=$(...) # <omitted> # extracting data archive into a ...
Edward Ruchevits's user avatar
1 vote
1 answer
34 views

Moving directories that names end in - number matching a list.txt file

Graphic of Folder Structure : I am very new to advanced shell commands and scripting. I have fundamental terminal knowledge but have never attempted to create an automation like this before. A pure ...
Roco Gman's user avatar
0 votes
0 answers
13 views

shc & gcc : Any use for the *.x.c. file that's created?

shc for "compiling" bash scripts, I end up with two files. One is obscured version of my bash script which works great, I also get an intermediate file *.x.c.. I say it this way because I'...
yegnal's user avatar
  • 31
1 vote
0 answers
83 views

MPV to play videos with a geometry

I have YOCTO build and I have integrated the mpv to the image. I need to test something so, I wrote a script that could play videos with a certain width and height and position on the screen but mpv ...
thehilmisu's user avatar
0 votes
2 answers
224 views

Bash provide comma-separated list in multiple lines

I have a bash script that is suppose to run another program called file-selector. #!/bin/bash ... ./file-selector -exclude="a/b/c/d/e/f1,a/b/c/d/e/f2,a/b/c/d/e/f3,a/b/c/d/e/f4,a/b/c/d/e/f5,a/b/c/...
Subzero123's user avatar
1 vote
1 answer
57 views

merge numbered files from different directories into same directory in correct order

I have some directories named FOO and BAR and etc. that have files in form FOO/ 1.png ... 18.png BAR/ 1.jpg ... 12.jpg ... and I would like them to be all copied into the DESTINATION directory ...
user3446323672's user avatar
0 votes
1 answer
74 views

The last command output in linux for reboot is not giving the uptime instead it says still running twice

[root@localhost test]# last -x reboot -s -30days reboot system boot 5.14.0-325.el9.x Sun Mar 10 10:51 still running reboot system boot 5.14.0-325.el9.x Tue Mar 5 03:05 still running In the ...
AshKash's user avatar
0 votes
1 answer
34 views

shell helper function wrapping `find` and ignoring some dirs

I have a bunch of scripts which follow the pattern of: find files which match a pattern do something The problem is that there are several "hazard" directories which are large and slow, ...
Tim Hockin's user avatar
0 votes
0 answers
97 views

How to run a batch script completely and automatically on event such as sleep/hibernate and shutdown event using task scheduler?

I have written a batch script to perform some folder synchronizing task. I have scheduled the script to execute using task scheduler on events such as sleep/hibernate(kernel power event id 42) and ...
Harsh's user avatar
  • 1
0 votes
1 answer
30 views

Why directories are not being expanded and some others are not created?

I am using Docker and I am trying to run the following script in the container which uses Alpine Linux and sh as a shell: Note: SCANDISK_MOUNT and SCAN_MOUNT are environment variables defined as var/...
ReynierPM's user avatar
  • 385
3 votes
3 answers
651 views

Bash [[ test =~ regex ]] vs perl command result

Is the bash operator =~ equivalent to a perl invocation? filename="test-33.csv" regex="([^.]+)(-\d{1,5})(\.csv)" With bash test: if [[ "$filename" =~ $regex ]]; then ...
rellampec's user avatar
  • 133
1 vote
1 answer
166 views

How to get the timestamp for the system lock/unlock of ubuntu 22.04 with the user's inactivity time? (Not login/logout.)

I want to get the user's lock & unlock timestamp in a single script or command, as in "last" command I can see the user's name with system's login & logout timestamp. How can I get ...
Mahesh Garole's user avatar
0 votes
1 answer
68 views

Loop of screens with a loop inside does not pick variable values

How can we execute a loop of screens, each of them executing a loop so that it picks both inner and outer variables? Consider this: # does not print i for i in 1 2; do screen -dmS screen-${i} ...
superAnnoyingUser's user avatar
0 votes
1 answer
151 views

How to convert code from test format to if fi format?

I have code that opens a bash file in a terminal for entering the sudo password: test "$IN_TERM" || { export IN_TERM=1 konsole -e "$0" exit 0 } && true I need ...
moninah's user avatar
  • 35
-1 votes
1 answer
30 views

How to get this desired output

I have this file: Alias name: ciscobas Owner: CN=DI0DGQB2QG9RK8OHMJ5C, O=Duo Security Issuer: CN=DI0DGQB2QG9RK8OHMJ5C, O=Duo Security Valid from: Thu Jun 15 15:08:49 AST 2023 until: Tue Jan 19 06:14:...
juan camilo bernal's user avatar
0 votes
1 answer
232 views

Reboot in middle of bash script

I'm writing a bash script to setup some services in Ubuntu. I require some system reboots between some steps. The problem with this is running reboot interrupts the script as well. Is there a way for ...
Voldemort's Wrath's user avatar
2 votes
0 answers
257 views

How can I close a browser window from a bash script?

I would like to open and close windows from a bash script but in my two versions of the code it gets stuck when it opens the first window and does not close the current window and then open the new ...
Bambino 's user avatar
0 votes
1 answer
230 views

Getting udev to check audio devices

I'm trying to write a udev rule for my bluetooth receiver which, when it connects, runs a script that checks whether a corresponding audio device has also been added, and reconnects if that is not the ...
sonofevil's user avatar
  • 127
0 votes
1 answer
88 views

How deep is too deep for Nested Folders in a Bash program?

I am somewhat new to Bash and am writing a program to install .NET SDK and Runtime on each of the available Linux distros. The problem I am having is that I am trying to source functions from two ...
sonAndrew's user avatar
  • 101
0 votes
0 answers
47 views

How to combine 2 rsync outputs into 1 command?

using: neofetch --stdout |grep 'OS:' OS: Kubuntu 22.04.3 LTS x86_64 Shell: bash 5.1.16 rsync --version rsync version 3.2.7 protocol version 31 variables, SourceDisK1 src1 and destination ...
joseph22's user avatar
  • 367
0 votes
0 answers
109 views

Perform lookup on two files

I have a csv file that get's SFTP'd to a RHEL box I have setup. It then gets transformed a little before another process SFTP's in and grabs it sending it off to be imported to a DB of a 3rd party. I ...
Jeremy's user avatar
  • 1
1 vote
2 answers
2k views

How can I use Windows command line to delete all files in a particular directory that were created on a specific date?

I accidentally blew up a tarball on my PC and now have something like 2 million unwanted files in my Documents folder. Windows Explorer crashes if I try to use it to view the contents of that folder, ...
ulfelder's user avatar
  • 111
-1 votes
1 answer
2k views

Echo all the output from a ls command

I have the follow files in my folder: a.jpg b.jpg c.jpg And I have the follow script: #!/bin/bash echo $1 If I run: script.sh $(ls) My output is: a.jpg But I want to be: a.jpg b.jpg c.jpg So, Why ...
Magenta's user avatar
  • 11
0 votes
1 answer
62 views

Complex find statement

Have a script that I use to purge old backup directories. All the directories are named YYYY-MM-DD. The backup directories have links in them as the backups are incremental using the rsync --link-dest....
Jeremy's user avatar
  • 1
0 votes
1 answer
62 views

rm not removing directory

Having a strange issue. Using a script to go through our backup folders and delete any folder not named like the 1st of the month (2023-05-01) and older than 60 days. It works in the sense that it is ...
Jeremy's user avatar
  • 1
1 vote
0 answers
82 views

How do you set qpdfview display options in a bash script?

Pseudocode: qpdfview **--continuous --2page-w-cover --zoom=167%** document-one.pdf#54 (or document-one.pdf#src:foobar.tex:42:0) & disown printf ' \n \n Some nice message \n \n ' read -p "...
YQ002lc2's user avatar
0 votes
1 answer
26 views

track filechanges on shared hosting account

So I like to keep track of added files but also edited files. find /home/user/public_html -type f -mtime -6 ! -path '*/exclude1*' ! -path '*/exclude2/etc*' -exec ls -ls {} \; | mail -e -s "File ...
Spacecabbie's user avatar
1 vote
1 answer
66 views

Incrementing of value not working inside "find"

I have a bash file that does a global update to files with a given name. I have used this script for several decades without any problems. I became curious as to how many files were being updated and ...
jwzumwalt's user avatar
  • 285
4 votes
1 answer
2k views

Ffmpeg: suppress warning when writing to a single image

Somewhere in the more recent versions, ffmpeg started printing this warning when I process png files: ffmpeg -i "src.png" -vf "$vf" "dst.png" The specified filename './...
Estecka's user avatar
  • 153
0 votes
0 answers
74 views

executing bash script on rotation with iio-sensor-proxy

I have a Tablet-laptop where i want to disable a gnome extension when the screen is rotated. Auto-rotation works via iio-sensor-proxy. it would be stupid to poll monitor-sensor constantly for resource ...
definitiv's user avatar
0 votes
2 answers
420 views

Bash printf: what does format specifier %P mean?

The printf statement : find directory1 -type d -printf "%P\n" | sort > file1 in the answer https://superuser.com/a/166322/856910 includes a format specifier %P. From the output of this ...
Leo's user avatar
  • 3
1 vote
2 answers
596 views

How do I run a bash script automatically everytime I hit CTRL + S?

I'm making frequent changes to a bash script and everytime doing "./demo_script.sh" is repetitive. Is there any way that it can automatically execute as soon as I hit CTRL+ S on keyboard?
lousycoder's user avatar
1 vote
0 answers
336 views

Sed editing of large text file much faster than native bash substring replacement?

I have a ~19MB text file which I would like to perform many find/replace operations on. I originally wrote the script to loop over inplace sed operations e.g. sed -i "s|$pattern|$replacement|g&...
Neuromancer's user avatar
0 votes
1 answer
77 views

Adding a user to an ubuntu linux group within a shell script

I'm writing a bash script to set up a docker application along with configuration etc. It's intended to run in a fresh Ubuntu install and be fully automated - just hit return and wait (albeit ...
Terminologist's user avatar
-2 votes
1 answer
245 views

Trap signal in Bash Terminal of linux

What it means to trap a signal? How to trap certain signal by its name or ID in bash? This below is the trap code. How to edit it so that it traps certain trap codes like 9, 20, etc. #! /bin/bash ...
Humza Config's user avatar
1 vote
0 answers
132 views

Running a bash script that calls R from within i3 does not work, but running it directly from the terminal works. Not sure if issue is i3 or not

I have a bash script that calls on R, and is mapped to a keyboard shortcut in my i3 config, like this: bindsym $mod+q exec --no-startup-id test-r-not-working-from-within.sh Here is a simple example ...
emilBeBri's user avatar
  • 121
2 votes
1 answer
844 views

List only bottom level directories using find

So, let's say I use find to search a directory for folders. find "/home/user/Documents" -type d -print While this does list all the directories in said location, I only want to get the ...
Eduardo Perez's user avatar
0 votes
3 answers
503 views

How to check in Bash if there is a file with an asterisk it its name

I've got an error in a Bash script that creates files with an asterisk ("*") in the name. I do not want this, so I'm trying to test at various points in the script if such a thing exists ...
4Dummies's user avatar
  • 183
1 vote
1 answer
295 views

Can't input text in Bash function called with key binding

I have added a simple function to my .bashrc file and bound it to a key combination using the bind command. The function prompts the user for input using read, like this: myscript() { read -p &...
Scooby-Doo's user avatar
0 votes
1 answer
134 views

Glob expression as an argument can not be printed

I am trying to write a simple bash script which would print the argument provided as an input to the terminal. echo "${1-nothing}" I have tried using $@ or without quotes. If I enter * as ...
Kay's user avatar
  • 1
-1 votes
1 answer
88 views

I need help finding the error in this bash script

I'm attempting to test my code, but I keep getting errors w/ everything I try. I will attach my code and the current error I am receiving. I am unsure what to change or adjust w/o changing the code ...
humsy419's user avatar
1 vote
1 answer
806 views

Can I and how to use `script` in a bash script

This must be the most frustrating research I've ever attempted (so far). So, there is script(1). I've been trying to add it to the start of a bash script I have (I was looking for a way to log every ...
João Ciocca's user avatar
0 votes
1 answer
144 views

Geany – display file path line

I’m a new Geany user. I code shell scripts on Linux. How to display "files path line" like this Geany image below ? I can't find any options in the Geany settings. Do I need to install a ...
Maxime's user avatar
  • 25
0 votes
1 answer
102 views

Ubuntu - Deleted service still working

I created an .sh file for my remote laptop that would play an alarm file through ffplay and send me a telegram message whenever the power plug got disconnected. The file worked great when I ran it in ...
qwerty's user avatar
  • 11

1
2 3 4 5
20