Skip to main content

Questions tagged [bash-scripting]

Bash scripting is making scripts in the Bash shell language.

Filter by
Sorted by
Tagged with
5 votes
2 answers
335 views

I have a lot of code with lines like the following: local -r foo="$(bar)" Just recently I discovered shellcheck and that warns about those assignments, because local hides the actual error ...
Thorsten Schöning's user avatar
0 votes
0 answers
72 views

I have a script like this listed on the device: { "type": "SCRIPT", "id": 67, "name": "script.run_application", "language&...
Bedrettin Tozlu's user avatar
2 votes
1 answer
135 views

I'd like to automate logging out and suspending the PC on Ubuntu 24 with LightDM. I tried this: SESSION_ID=$(loginctl | grep $(whoami) | awk '{print $1}') loginctl terminate-session "$SESSION_ID&...
davidair's user avatar
  • 175
9 votes
10 answers
2k views

I am attempting to write a script depending on the version of Debian. I have tried the following: #! /bin/bash DEBVERS=$(awk '{print $1}' /etc/debian_version) echo "DEBVERS = " $DEBVERS if [[...
Milliways's user avatar
  • 672
2 votes
1 answer
177 views

Good day, I have a directory with all my customers. (Auto Electrical). Inside every customer's directory is another directory with every booking they have booked with me before: -John_Smith --...
Danny's user avatar
  • 23
2 votes
2 answers
184 views

I am new to Bash and wanted some help. I have a command which produces four lines and I would like these lines to be fed to four variables, so i can use them in the next command. could someone please ...
Swetank Jackson's user avatar
0 votes
0 answers
60 views

I'm experimenting with Docker images having 20-70 GiB in a single layer (yes, the software/compiler is so fat). To improve the download and decompression efficiency of Docker, I'm splitting this fat ...
Paebbels's user avatar
  • 189
0 votes
2 answers
120 views

I have a bash script I am using to deploy updates automatically. It also includes logs of when the updates have been run. I have added the entire bash script below. The issue I am having is within ...
Kyle Sanders's user avatar
0 votes
0 answers
93 views

I'm trying to use find command with a backslash on the command below at groovy syntax: stage("ArtifactRename") { sh '''find "./os/mcu/GNU ARM v10.2.1 - Debug" -name "\\...
Sundeep Kumar Gorantla's user avatar
1 vote
1 answer
87 views

~$ echo $(date +%a%d\ %X) lun.24 17:40:28 ~$ inode-1 thunar.desktop lun.24% +17:40:40 ~$ cat inode-1 #/bin/bash # inode_check xdg-mime query default inode/directory >> /home/<user>/f1; ...
mazda's user avatar
  • 495
-1 votes
1 answer
401 views

Is jq guaranteed to always output valid json, even if it encounters an error while running? Error could be due to poorly formatted input, for example. Outputting valid json and not outputting anything ...
ghosts_in_the_code's user avatar
1 vote
0 answers
430 views

I can use syntax as below to list 6 files named a1b.md, a2b.md, a3b.md, x1y.md, x2y.md, x3y.md in a directory: ls a{1,2,3}b.md x{1,2,3}y.md I'd like to use something like this in a bash script; with ...
user74094's user avatar
  • 386
0 votes
1 answer
199 views

Hi everyone and thank you in advance! I used to run the following script with ncat Version 5.51 and it gave me wonderful formatting [root@server user]# for i in "cat server_list" ; do echo $...
ShadyYogaInstructor's user avatar
1 vote
1 answer
180 views

So I have to run a basic shell script that is not much more than: #!/bin/bash call01 call02 ... call_N If one of the calls fails (gets killed by the OS because it runs out of memory), what does it ...
Yuri Makassiouk's user avatar
3 votes
1 answer
119 views

How can I interrupt a bash script until either n seconds have passed or any key has been pressed? What I have been trying so far was to combine a loop like while [ $n -gt 0 ] ; do n=$(($n-1)) ...
jetrca's user avatar
  • 53
1 vote
0 answers
112 views

I'm currently making a script to cap my videos at just slightly below 60 seconds. So if I have a video clip that is exactly 60 seconds long, I trim it by exactly 1 frame so it is slightly below 60 ...
Harry McKenzie's user avatar
0 votes
1 answer
323 views

I am writing a shell script in Bash. Within the Bash terminal I am using "CLI" commands to do some function. In this example I am creating a model, that if the syntax is correct, will ...
Dan Lundwall's user avatar
1 vote
0 answers
58 views

In bash scripts I sometimes use a command of the form xtrace -o xtr.txt 2> /dev/null command-of-interest to obtain info about 'command-of-interest' that is otherwise unobtainable. But this starts ...
user985675's user avatar
0 votes
0 answers
327 views

I have long been in the process of converting my manual steps to create a new backup disks into an automated script. The only part I have left is the initial "creation" of the disk, meaning ...
user20986345's user avatar
2 votes
0 answers
415 views

I want to download a lot of satellite data (organized by each day of each year) in .hdf format from NASA's LAADS DAAC archive. They have a helpful guide that provides a code sample to use with GNU ...
Seyong Chang's user avatar
0 votes
1 answer
839 views

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
138 views

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
147 views

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
  • 199
0 votes
1 answer
241 views

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
1 vote
0 answers
1k views

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
  • 183
0 votes
3 answers
133 views

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
666 views

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
66 views

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
1 vote
0 answers
688 views

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
823 views

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
105 views

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
366 views

[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
1 vote
1 answer
70 views

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
206 views

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
63 views

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
  • 395
3 votes
3 answers
1k views

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
488 views

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
201 views

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
180 views

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
  • 45
-1 votes
1 answer
59 views

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
805 views

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
518 views

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
489 views

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
  • 147
0 votes
1 answer
182 views

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
  • 163
0 votes
0 answers
79 views

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
  • 529
1 vote
2 answers
5k views

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
4k views

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
  • 21
0 votes
1 answer
109 views

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
123 views

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
2 votes
0 answers
182 views

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
  • 121

1
2 3 4 5
20