Questions tagged [shell]
The shell is Unix's command-line interface. You can type commands in a shell interactively, or write scripts to automate tasks. Use this tag for questions applying to /bin/sh and most compatible shells (ash, bash, ksh, zsh, …). For shell scripts with errors, please check them in http://shellcheck.net before posting here.
12,267 questions
-4votes
0answers
51views
Creating in Linux files in GB or MB range by various random size by read a file [closed]
In Linux in Bash i have this script (thanks to Ed Morton) . $ cat ./tst.sh #!/usr/bin/env bash while read -r idx sfx size; do echo fallocate "file${idx}.${sfx}" "$size" done &...
-2votes
1answer
110views
Creating in Linux files in GB or MB range by various size by read a file [closed]
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 ...
9votes
3answers
784views
How to delete buffered text written to terminal during script execution
Let's say hypothetically I'm executing a long-running bash script, and while it's running, I accidentally right click on the terminal and paste a sensitive password (freshly copied out of a password ...
4votes
3answers
533views
Parse console output and audibly say error
I am testing testing app by running mycommand that outputs at the console and directly at /tmp/mycommand.log. Using zsh. mycommand is really a function with parameters, but I can get the same when ...
5votes
2answers
373views
How (internally) does fd3>&fd1 after { fd1>&fd3 } put back (or not) original fd into fd1? ("bad file descriptor")
`I'm reading an answer to https://stackoverflow.com/questions/692000/how-do-i-write-standard-error-to-a-file-while-using-tee-with-a-pipe/692009#692009, https://stackoverflow.com/a/14737103/5499118: { {...
0votes
1answer
103views
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 ...
4votes
1answer
164views
Run in background avoiding any job control message from the shell [duplicate]
Lets define a shell function (here the shell is Bash) and test it $ s () { xterm -e sleep 5 & } $ s [1] 307926 $ [1]+ Done xterm -e sleep 5 $ With my specific meaning of ...
9votes
2answers
1kviews
What is this icon (dots over a gray curving line) that momentarily appears in my GNOME status bar?
The leftmost icon () is the one in question. For context, I have a pair of multipoint Bluetooth earbuds simultaneously connected to both my iPhone and Linux laptop. When I'm listening to music on my ...
12votes
1answer
994views
Why doesn’t `sudo -E` preserve `PERL5LIB`?
I’m experiencing a strange behavior related to environment variable preservation with sudo on macOS(15.2): sudo -E doesn't preserve the environment variable PERL5LIB. Reproduction Steps Set an ...
0votes
2answers
97views
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 <&...
3votes
1answer
151views
Bash redirections - handling several filenames specially (man pages)
Please confirm/correct me. I've found related Duplication of file descriptors in redirection but that does not answer my specific question. From the The GNU Bash Reference Manual, section 3.6 ...
0votes
2answers
87views
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: ...
0votes
0answers
32views
Retry CLI tool for Linux [duplicate]
I often find myself needing something to retry commands that are 'likely' to fail for non-critical reasons and can just be reattempted a few times, such as periodic rsync jobs, metric collection/...
0votes
0answers
46views
Shell script not behaving as expected expanding variable as command [duplicate]
I am trying to script a job which interacts with mysql. I am using a variable to store a long command line. But when run via a script this does not behave as expected. I can reproduce the issue as ...
0votes
1answer
42views
What is (if any) the file descriptor of /dev/tty?
The urgent issue to read keyboard input in the pipeline is solved by the answer in https://stackoverflow.com/questions/15230289/read-keyboard-input-within-a-pipelined-read-loop: mycommand-outputpiped |...