Questions tagged [shell-script]
A shell script is a script written for the shell, or command line interpreter, of an operating system.
1,464 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
3
votes
0
answers
78
views
How can I run a ps1 script from the context menu in Windows Terminal - but ALWAYS open a new WT window instead of the script running in a new tab?
I have set up some right-click context menu entries for .ps1 files to run PowerShell scripts in Windows Terminal instead of ConHost. Screenshot:
So I can run a one-off script elevated or un-elevated ...
2
votes
2
answers
183
views
How to change a string on the line for a specific parameter (we don’t know the string value) in a Linux Bash script?
Please note that I have done some search and tried different solutions with sed/awk and nothing worked. I'm stuck, so I posted the question here requesting your help.
Let’s say that there's a generic ...
0
votes
0
answers
78
views
How to automatically execute an interactive script at terminal startup?
I got a pretty simple script for my Raspberry PI 5 which I intent to use primarily as a media center. In pseudocode, it does:
You got 5 seconds to press key
if no key pressed
launch desktop ...
3
votes
1
answer
421
views
How to write ${...} as text in file
I'm writing a shell script that creates a file; the text inside the file must contain the string ${...}, which doesn't have to be treated as a variable but as pure text.
tee -a /etc/apt/apt.conf.d/...
0
votes
0
answers
212
views
Download requests using tools like wget/yt-dlp get redirected by site to lower resolution dl
TLDR
Attempted automated downloading of files through scripts and tools like wget/yt-dlp results in the site redirecting from the higher resolution file requested to a lower resolution version. This ...
0
votes
1
answer
91
views
How can I build a script to continuously query mdutil on a volume until it stops indexing releasing that resource to being able to disable it?
I need to turn off the indexing/Spotlight in a volume to rebuild the index/search.
(To then: Full Disk Access >> sudo rm -rv /Volumes/MY-VOLUME/.Spotlight-V100 >> sudo killall mds >>...
2
votes
2
answers
244
views
How to programmatically determine if APT is doing an update?
General overview
I am currently developing a widget for Debian to show the number of the updates complete and the total number of packages to update.
The desired rendering could be something like:
...
6
votes
2
answers
394
views
What's the idiomatic way to process input stream in chunks?
seq 100 | ... wc -l
What can fill in for ... so that that wc -l prints 10, ten times? A clunky way I can think of is:
seq 100 | xargs -L10 bash -c '(for i; do echo $i; done) | wc -l' bash
Wondering ...
0
votes
2
answers
100
views
Linux equivalent to `cp -R source/ dest`? Copy all files *under* source into dest
Today I learned that the FreeBSD cp utility (as found on Mac OSX) has a useful special behavior for cp -R dir1/ dir2. Namely:
-R — If source_file designates a directory, cp copies the directory and ...
17
votes
2
answers
2k
views
Setting up a cron job which runs on the Monday of the week which contains the 3rd Thursday
How do I set up a cron job which runs on Monday of the week when there is a 3rd Thursday?
Example, in March the 3rd Thursday is on the 20th, so the job needs to run on 17th which is a Monday.
...
6
votes
3
answers
2k
views
Bash script that waits until GPU is free
If my PyTorch training script is run twice at once, the second run will fail due to not having enough GPU memory.
So, I want a bash script that I call like ./scripts/wait.sh && ./scripts/train....
1
vote
1
answer
333
views
Run bash scripts on KDE Plasma sleep and wakeup events of Power Management as a particular user?
KDE Plasma 5.27.11 on Debian 12 amd64
I need to send some very short signals over USB on workstation's power management sleep and wake up events(not login and log out, they work fine). I have prepared ...
0
votes
1
answer
313
views
Returning a Value from an external operation in shell script in Linux?
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 ...
2
votes
1
answer
232
views
Create a visual diff between two images and overlay it on one of these using imagemagick
I have two images (of a schematic) and I want to highlight the differences on one of them:
Using imagemagick I can create the visual diff and I can also overlay it over the second image:
compare ...
0
votes
0
answers
471
views
How can I create a command to activate a Python virtual environment across different shells with minimal complexity?
I'm developing a tool that needs to activate a Python virtual environment using a custom command. Currently, I'm using the following alias in my .bashrc file:
alias activate_env="source ./env/bin/...