All Questions
Tagged with shell-script shell
2,432 questions
-2
votes
0
answers
37
views
Creating in Linux files in GB or MB range by various size by read a file
In Linux with Bash, there is the File numbers_in_one_line.
In this file there is only one line with several numbers, all separated by spaces.
These numbers are the value in bytes for creating files ...
0
votes
1
answer
103
views
How to compare output of a program with a reference value in a shell script?
I have my own implementation of a Redis server which I'd like to test through a shell script.
The general idea is to feed it with some commands through nc, and since nc prints the output of my program ...
0
votes
2
answers
97
views
How to redirect output from a program that waits for input
Following this post I created my own version of the script, with the difference that user and password are forwarded from the environment variables:
#!/bin/zsh
pamtester login $user authenticate <&...
0
votes
2
answers
87
views
how do i use pv in a script that has a seq for loop
I have a script that has a for loop in it that runs a specific amount of times, and I was wondering if it is possible to implement the pv command in my script to add a progress bar.
Here is my code:
...
1
vote
1
answer
66
views
How can a bash script determine how it was started? [duplicate]
I am running various scripts on Debian 12.X currently with the following bash:
GNU bash, version 5.2.15(1)-release (x86_64-pc-linux-gnu)
I have the following methods/options to execute the script.
...
0
votes
5
answers
128
views
Move/mark files and the associated-part too
There is a folder with many files in it:
112.mkv
123.md5
123.mkv
221.mkv
467.mkv
aa1.mkv
abc.md5
abc.mkv
bbc.mkv
dde.md5
dde.mkv
ggh.mkv
....
xxy.md5
xxy.mkv
xxz.mkv
How can I move .md5 files and the ...
2
votes
1
answer
894
views
What do programs use to read their environment?
I'm on Fedora, where all preinstalled shells apparently support bashisms: bash --posix does, and even sh. Still, when I used this function,
pathprepend () {
if [[ ":$PATH:" != *":$1:...
0
votes
0
answers
33
views
Can't use combination of parentheses and variables in scripts [duplicate]
I have problems with replacing parentheses in combination with variables, in ssh.
For instance, replacing (hello123blablabla) with (hello). So, it replaces all together, and parentheses as well, at ...
0
votes
1
answer
304
views
How to use docker exec to execute a shell script with an argument in a container?
I have a shell script on my host, which is calling another script to run inside the container. Here is a simple case that works fine:
host_script.sh
#!/bin/sh
results=$(docker exec mycontainer "....
1
vote
1
answer
100
views
Open pdf files by terminal with fzf and fd
with the following command line, which I turned into an alias, I would like to open the pdf files from my terminal.
alias pdfLoad="fd . '$HOME/OneDrive/DBCalibre' -t f -e pdf | fzf | xargs -0 -...
4
votes
1
answer
266
views
How to detect if headphones are plugged in for a shell script?
I'm writing my own custom status for i3/Sway that shows a volume indicator, and I've run into a snag.
I'd like to know if there is a standard way, using standard Linux tools--maybe ALSA or sysfs--to ...
0
votes
1
answer
27
views
How to start tree of applications with dependencies
I need to be able to automatically start a requested application.
Every application can have pre requisite applications that need to be started before it starts, and an application can itself be a pre-...
2
votes
1
answer
328
views
Can one execute a function in background from a function that is already running in background?
Considering the following script:
if [[ -z "$DOWNLOAD_ONLY" || "$DOWNLOAD_ONLY" = *conditions* ]]; then
function get_condition {
curl -s "https://conditions.com" | ...
0
votes
1
answer
33
views
Symlinks with data inside directory
I'm using this symlinks
ln -s "$REPO_DIR/src/packages/my-project/out" "$OUTPUT_PATH"
Currently, my OUTPUT_PATH only has only 1 folder out
How can I make my OUTPUT_PATH has all the ...
0
votes
1
answer
73
views
Open 2 mate-terminal instances and run commands
I am trying to set up a script that runs 2 mate-terminal instances, each with a different command.
The script is set up as a cronjob.
The problem is, while the script works fine when executed manually,...