Skip to main content

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.

Filter by
Sorted by
Tagged with
0 votes
1 answer
16 views

It often happens that I have some long task running, like compiling a program, running tests or copying large archives. Once I am done with whatever else I was doing, I want to leave the computer ...
Dominik Kaszewski's user avatar
5 votes
2 answers
826 views

I am using this code to parse the first argument passed to my script. It error handles and it works just the way I want it: if [ -z "$action" ]; then printf "[${c_RED}ERROR${c_RESET}...
EmberNeurosis's user avatar
3 votes
1 answer
100 views

$ wine cmd /c 'echo "hello world"' \"hello world\" Where do the backslashes come from? The command behaves differently in an interactive session: $ wine cmd Microsoft Windows 6.1....
finefoot's user avatar
  • 3,586
4 votes
1 answer
196 views

Suppose we have a script named test_sort in our $PATH with the following contents: #!/bin/bash function echo_text () { printf -- "%s\n" "$fc$oc$fs$lc" printf -- "%s\n&...
Melab's user avatar
  • 4,476
1 vote
2 answers
63 views

Here is a sample directory tree as it would appear if it were sorted in character code order (i.e., directories are not listed first): ${PREFIX}/ .bashrc .include.sh.d/ common.sh ...
Melab's user avatar
  • 4,476
14 votes
2 answers
1k views

I of course realize the need to have something that separates the condition to the actual commands to be executed under the control statement, but why were it chosen to use both semicolon and a ...
skyking's user avatar
  • 492
0 votes
0 answers
40 views

What do I want : On the file manager lf, we can bind some keyboard shortcuts to do either a lf command with :, or a shell command with $, !, or other symbols. According to the documentation, there is ...
ewen-goisot's user avatar
5 votes
2 answers
267 views

In the old times of DOS batch scripts, the only way to check for a variable to be empty or to allow an empty variable was to prepend (or append) a known letter, commonly the letter x, because there ...
Rainer Glaschick's user avatar
0 votes
0 answers
56 views

In a code review on Final look at my Lightshot print screen Linux handler POSIX shell script, specifically in this short answer, it has been pointed out to me, that if there are multiple X servers ...
Vlastimil Burián's user avatar
0 votes
0 answers
43 views

Context I have a system user caddy and a shell script placed under /run/caddy/caddy-cert-obtained-wrapper.sh. /run and /run/caddy are owned by root:root with permissions 0755. caddy-cert-obtained-...
Martin Tovmassian's user avatar
-1 votes
2 answers
104 views

Welcome to Termux Docs: https://doc.termux.com Community: https://community.termux.com Working with packages: - Search: pkg search <query> - Install: pkg install <package> - ...
Swudu Susuwu's user avatar
2 votes
1 answer
618 views

I have seen code like this in a /bin/sh script: repo_files=$(git ls-files) && There is no line continuation. What is the purpose of && at the end of a line like this? Can the '...
PRouleau's user avatar
  • 305
-4 votes
1 answer
228 views

In the below shell script I'm executing the some command cmd remotely where in the command output is redirected to some file cmd_log. I'm getting the desired result as long as the command cmd itself ...
Harry's user avatar
  • 239
10 votes
4 answers
947 views

Without ;;&, /bin/sh gives Syntax error: ")" unexpected (expecting ";;"). ;;& triggers shellcheck's ^-- SC2127 (error): To use cases with ;;&, specify #!/usr/bin/env ...
Swudu Susuwu's user avatar
5 votes
1 answer
291 views

If do this on my bash terminal: ( (sleep 0.5 && echo 'first command, second result' &); (echo 'second command, first result' &); ) then I see: second command, first result ...
k0pernikus's user avatar
  • 16.7k
7 votes
1 answer
285 views

This question asks how to get a list of environment variable names in POSIX sh. The top answer suggests invoking awk via the shell, but gives this caveat: The output is ambiguous if the name of an ...
emron's user avatar
  • 365
4 votes
3 answers
520 views

I have a bash shell script that runs via cron. The script looks for 1 of 6 possible (data) files in a directory. If 1 or more of these files is found, a new (control) file is created for each data ...
Richard Steffy's user avatar
3 votes
2 answers
149 views

POSIX defines shell functions as: fname ( ) compound-command [io-redirect ...] The compound-command is further defined as either: ( compound-list ) { compound-list ; } In particular POSIX notes for ...
Chris Davies's user avatar
11 votes
5 answers
1k views

I would like to be able to search all my $PATH for files matching a given pattern. For example, if my PATH is /usr/local/bin:/usr/bin:/bin and there's a /usr/local/bin/gcc-4 and a /usr/bin/gcc-12, I ...
umläute's user avatar
  • 6,734
0 votes
1 answer
55 views

I'm quite new to Linux. Recently, I've been able to create a bash script that allows me to obtain the RSSI of the receivers (or node) with a running iteration. How can I store these results in an text ...
Trinh Dat's user avatar
0 votes
1 answer
832 views

I met an interesting issue while working with this code from Stack Overflow: tripleee's answer on "How to check if a file contains only zeros in a Linux shell?" Why does the same bash code ...
Андрей Тернити's user avatar
3 votes
0 answers
752 views

Updated Just booted the PC and now it works. >echo $SHELL /bin/bash Very strange. Logging out and back in was not enough. Just installed new CachyOS linux on new PC (not virtual box) I looked at ...
Nasser's user avatar
  • 1,011
6 votes
1 answer
515 views

Suppose I want to sync the contents of a directory (source_dir) using rsync without creating a directory named source_dir in the target directory. I can do this using rsync source_dir/ target_dir or ...
jdoe's user avatar
  • 63
3 votes
2 answers
174 views

I have a minimalistic pod that holds a small python program. I've added the source to $HOME/.profile but it does not autorun. How can I autosource it when I log in? docker run -ti <internal-docker-...
MortenB's user avatar
  • 413
2 votes
1 answer
530 views

how do you supply a literal asterisk * when specifying a filename to a command substitution in bash? Consider the following directory: host:/tmp/backtick-test# ls -l total 0 -rw-r--r-- 1 root wheel ...
Scott's user avatar
  • 103
0 votes
0 answers
55 views

Is there any extension of linux filesystems that can solve uri paths in terminal to avoid doing things like: cat https://example.com/file.txt cat file:///some-file-path/file.txt instead of curl -vs ...
arthur.afarias's user avatar
4 votes
0 answers
123 views

The window of my text editor Xed froze with Unsaved documents just as I was doing 'File'->'Save as...' to save them... [How ironic.] Since the process still exists, I am trying to recover the text ...
The Quark's user avatar
  • 454
0 votes
0 answers
55 views

So I've been doing CTF Tryhackme called mKingdom and got a remote shell. However, I want an upgrade of the remote terminal so I ran python3 -c 'import pty;pty.spawn("/bin/bash")' , it showed ...
McK's user avatar
  • 1
0 votes
1 answer
94 views

There are processes that ignore SIGHUP signals like: docker run -it -p 1521:1521 -eORACLE_PASSWORD=atk4_pass gvenzl/oracle-xe:18-slim-faststart Currently, when I close the console, the docker command ...
mvorisek's user avatar
  • 251
0 votes
2 answers
123 views

Environment: shell is BusyBox bash 3.2 running in what started-out as Ubuntu Server many years ago, but has since been tweaked a great deal by the manufacturer of this particular box to become a ...
OneCheapDrunk's user avatar
0 votes
1 answer
245 views

According to BASH manual page, When Bash receives a SIGINT, it breaks out of any executing loops. In all cases, Bash ignores SIGQUIT. So if there was a shell script, started from bash shell, to ...
KDM's user avatar
  • 128
2 votes
4 answers
184 views

I have a dataset of images labeled/classified by characteristics, where an image can have more than one label. I want to count how many of each identifier I have. A toy dataset is created below, with ...
bballdave025's user avatar
0 votes
2 answers
103 views

My login shell is Fish, but I would like to execute a shell command (apt install ...) as if my login shell was Bash. Is it possible to make a command/subprocess believe that my login shell is /usr/bin/...
Alexey's user avatar
  • 2,380
11 votes
1 answer
1k views

As far as I know, sudoedit gives a user permission to edit a file that is owned and writable by root. It makes a copy of that file, the copy is owned by the user, and then it spawns a text editor with ...
codeandfire's user avatar
0 votes
0 answers
63 views

I've recently started to observe unexpected output (and later stty -a outputs terminal settings different from new shell tab) from my shell scripts project. As of now, I'm very close to be sure the ...
Alex Martian's user avatar
  • 1,319
-4 votes
1 answer
89 views

Although this is easy to try and see, I was looking for the answer on StackOverflow and couldn't find it. That's why I'm asking and answering my question. I recommend reading this first. The answer is ...
Daniel Kaplan's user avatar
1 vote
1 answer
102 views

In Visual Code, on Windows 10, I'm trying to create a function for my .sh project (which I run with Git Bash), which will report errors to the console in case user, let's say, provides fewer or more ...
Simos Sigma's user avatar
0 votes
0 answers
39 views

https://www.gnu.org/software/bash/manual/html_node/Quote-Removal.html 3.5.9 Quote Removal After the preceding expansions, all unquoted occurrences of the characters ‘\’, ‘'’, and ‘"’ that did ...
Martian2020's user avatar
  • 1,483
5 votes
1 answer
348 views

https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html When braces are used, the matching ending brace is the first ‘}’ not escaped by a backslash or within a quoted string,...
Martian2020's user avatar
  • 1,483
0 votes
1 answer
49 views

On my machine, there is a file: /var/lib/flatpak/exports/bin/com.github.tchx84.Flatseal Which is a symlink whose content is: ../../app/com.github.tchx84.Flatseal/current/active/export/bin/com.github....
Tom Anderson's user avatar
  • 1,128
2 votes
1 answer
229 views

I'm looking for a command that compares binary files. Of course, I know about diff, but it is not very good at binaries. I have two files from a error-prone source (scratched dvd) which should be ...
Gyro Gearloose's user avatar
3 votes
1 answer
233 views

I'm trying to make an alias or a function that will execute a shell script or a file without holding up a terminal. So far I've figured out a command that'll do that, but I'm having trouble turning it ...
Nerys Halcyon's user avatar
-3 votes
1 answer
151 views

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 ...
user447274's user avatar
9 votes
3 answers
883 views

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 ...
Ivoirians's user avatar
  • 193
4 votes
3 answers
616 views

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 ...
TimSO's user avatar
  • 63
5 votes
2 answers
439 views

`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: { {...
Alex Martian's user avatar
  • 1,319
0 votes
1 answer
241 views

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 ...
ivanbgd's user avatar
  • 111
4 votes
1 answer
297 views

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 ...
gboffi's user avatar
  • 1,406
9 votes
2 answers
2k views

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 ...
rdong8's user avatar
  • 93
12 votes
1 answer
1k views

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 ...
LuckyJollyMoments's user avatar

1
2 3 4 5
246