Questions tagged [bash-scripting]
Bash scripting is making scripts in the Bash shell language.
972 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
0
votes
0
answers
58
views
How to use NinjaRMM to run an application via API?
I have a script like this listed on the device:
{
"type": "SCRIPT",
"id": 67,
"name": "script.run_application",
"language&...
2
votes
1
answer
128
views
How do I write a script that logs me out and suspends a PC running Ubuntu 24 with LightDM?
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&...
9
votes
10
answers
2k
views
How to compare numeric strings in Bash?
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 [[...
2
votes
1
answer
171
views
Bash script iterate through directory and delete zip file
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
--...
2
votes
2
answers
180
views
Multiple result lines from bash feeding into multiple variables
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 ...
0
votes
0
answers
60
views
Are xarg + cp vulnerabler to race conditions?
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 ...
0
votes
2
answers
119
views
preserve variable within bash script
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 ...
0
votes
0
answers
93
views
Jenkins Groovy syntax not working for find command
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 "\\...
1
vote
1
answer
87
views
The output of a bash command changes if executed by a script
~$ 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;
...
-1
votes
1
answer
389
views
Will jq output valid json even if error?
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 ...
1
vote
0
answers
418
views
Store bash glob pattern in a variable
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 ...
0
votes
1
answer
188
views
How to run ncat -zv without showing version on RHEL7?
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 $...
1
vote
1
answer
179
views
Exit code of a bash script when one of the steps fails?
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 ...
3
votes
1
answer
116
views
Do until either n seconds have passed or any key has been pressed
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))
...
1
vote
0
answers
110
views
How can I cap video length to just slightly below 60 seconds without re-encoding with FFmpeg?
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 ...