Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Favorites infavorites:mine
infavorites:1234
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with Search options answers only user 281844

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.

3
votes
To explain the problem you're seeing, it's happening in the second sed command: sed -e 's/\//\\/g' make uses \ as a special character that can be used to escape %, so \\ is an escape sequence that …
modified May 13 by filbranden
21
votes
Instead of having myprg magically detect whether it is being used in a shebang, why not make that explicit by using a command-line flag (such as -f) to pass it a file as a script? From your example i …
modified May 6 by Kusalananda
1
vote
Creating a directory with the same name as a file is not really possible on any Linux or Unix (that I know of, at least.) But that's not really what the script is trying to do. If you look carefully …
modified Feb 8 by filbranden
41
votes
The cd command is a built-in, so normally builtin cd will do the same thing as cd. But there is a difference if cd is redefined as a function or alias, in which case cd will call the function/alias bu …
modified Jan 20 by filbranden
13
votes
In short, printf %100s will print 100 spaces, and tr " " "=" will convert those spaces to equal signs, effectively printing 100 equal signs. Breaking it down: printf is a shell built-in. It …
modified Jan 6 by Jeff Schaller
5
votes
TL;DR: When taking a command on the "--shell" or "--login" options, sudo will escape most characters (using backslash escapes), including all metacharacters (except for $), also including spaces … . That breaks about every use case where you'd want to use a shell, which makes sudo -s mostly unsuitable to run shell commands that need to run as shell commands. Instead of sudo -s, use sudo sh -c …
modified Nov 27 '18 by filbranden
2
votes
The difference is that echo is a built-in of your shell, while /bin/echo is an external executable. The limitation on ARG_MAX is on the kernel syscall to execute an external binary (execve(2 … ).) When executing a built-in in your shell, no such limitations are imposed by the system, only limitations are from the shell itself, and most shells will simply not impose limits other than the memory …
modified Nov 23 '18 by filbranden
1
vote
(defaults to printing the unmodified line), or maybe a print of specific fields. Please note that the formatting is helpful in seeing how your blocks nest! This is perfectly valid syntax, the shell takes …
modified Oct 23 '18 by filbranden
2
votes
As a general solution, you can pass additional environment variables to a sudo command using possibly multiple VAR=value pairs in the command-line to be executed. In this particular case, to pass the …
modified Sep 1 '18 by filbranden
2
votes
You can use the -j option to zip (-j for "junk paths") which will discard the name of the directory and keep only the file name. Also, you don't need the -r option (-r for "recurse into directories") …
modified Jul 28 '18 by filbranden
0
votes
You can use awk for that: file=$(declare -F my_bash_func | awk '{print $3}') Or use bash built-ins, read it into an array: func_info=( $(declare -F my_bash_func) ) file=${func_info[2]} line_number …
modified May 2 '18 by filbranden
4
votes
You should look into bash "restricted" mode (started with bash --restricted or bash -r), which prevents commands such as cd and blocks running any executable by the full path, so it only allows execut …
modified Apr 26 '18 by filbranden
2
votes
You should pass ssh the -t option, so it allocates a tty (terminal) on the remote side for running your script. Commands that need to prompt for a password (such as sudo) need a terminal, so they can …
modified Apr 18 '18 by filbranden
0
votes
The shebang line typically only takes at most two arguments, so it's considering "awk -f" as a single argument to env. Considering you know the path to your awk, using that directly should fix the pr …
modified Apr 17 '18 by filbranden