
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 …
shell - How to go to the previous working directory in terminal?
The echo shows the new directory not the previous one. And I would find it useful, so that I know where I am now, especially if I'm in a shell that only shows the current directory name (or …
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 do integer & float calculations, in bash or other ...
Jun 14, 2013 · Using POSIX shell functions, and awk math power, just define this (one line) function: calc(){ awk "BEGIN { print $*}"; } Then just execute things like calc 1+1 or calc 5/2. …