
What does $# mean in shell? - Unix & Linux Stack Exchange
You can always check the man page of your shell. man bash says: Special Parameters # Expands to the number of positional parameters in decimal. Therefore a shell script can check …
shell - What is the "eval" command in bash? - Unix & Linux Stack …
In shell terminology, eval is a built-in, not a function. In practice, built-ins behave a lot like functions that don't have an in-language definition, but not quite (as becomes apparent if you …
shell - How to check OS and version using a Linux command
Kernel Version. If you want kernel version information, use uname(1). For example: $ uname -a Linux localhost 3.11.0-3-generic #8-Ubuntu SMP Fri Aug 23 16:49:15 UTC 2013 x86_64 …
How do I remove a directory and all its contents?
Aug 17, 2012 · If rm -r doesn't work, that would be an OS issue, not a shell issue. (Strictly speaking, it would be an issue with the version of rm that you're using, so you could address it …
Shell scripting: -z and -n options with if - Unix & Linux Stack …
You can find a very nice reference for bash's [aka test builtin's operators here, or by running help test in a bash shell or info bash test or info bash '[' from any shell¹. If you are using a different …
Running a shell command as root - Unix & Linux Stack Exchange
On many systems booting into single user mode will give the user access to a root shell without prompting for a password. Notably, systemd-based systems will prompt you for the root …
How to conditionally do something if a command succeeded or …
It's probably the most common command to use in an if, which can lead to the assumption that it's part of the shell's syntax. But if you want to test whether a command succeeded or not, use …
shell - What does "--" (double dash / double hyphen) mean?
In man bash we can read in Shell Builtin Commands section : Unless otherwise noted, each builtin command documented in this section as accepting options preceded by -accepts --to …
shell - How to catch an error in a linux bash script? - Unix & Linux ...
Oct 23, 2013 · The only thing that you need to be aware of when using this method is that all modifications of Shell variables done from the command you pass to run will not propagate to …
login - How to switch between users on one terminal? - Unix
Oct 27, 2010 · Generally, you can use sudo to launch a new shell as the user you want; the -u flag lets you specify the username you want: $ whoami user1 $ sudo -u user2 zsh $ whoami …