Yahoo Web Search

Search results

  1. 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 how many parameters are given with code like this: if [ "$#" -eq 0 ]; then echo "you did not pass any parameter" fi

  2. Feb 20, 2011 · This latter usage is faster, does not contaminate the shell's variable namespace with what amounts to temp variables, can often be a lot more readable for humans and encourages the use of "positive logic", the practice of writing conditionals without negations, which has cognitive simplicity in most situations.

  3. May 8, 2012 · A login shell is the first process that executes under your user ID when you log in for an interactive session. The login process tells the shell to behave as a login shell with a convention: passing argument 0, which is normally the name of the shell executable, with a -character prepended (e.g. -bash whereas it would normally be bash).

  4. Here documents are commonly used in shell scripts to create whole files or to display long messages. cat > some-file <<FILE foo bar bar bar foo foo FILE < passes the contents of a file to a command's standard input.

  5. See What is the difference between > and >> (especially as it relates to use with the cat program)?, What does “3>&1 1>&2 2>&3” do in a script? and of course, your shell's manual. (There are some further explanations in Is this a typo in Bash manual's redirection section? too.) –

  6. I know about the following ways to spawn processes from the shell: exec /path/to/Program replace shell with the specified command without creating a new process; sh -c /path/to/Program launch shell dependent process /path/to/Program launch shell dependent process /path/to/Program 2>&1 & launch shell independent process

  7. You can always try the obvious things like ^C, ^D (eof), Escape etc., but if all fails I usually end up suspending the command with ^Z (Control-Z) which puts me back into the shell. I then do a ps command and note the PID (process id) of the command and then issue a kill thePID ( kill -9 thePID if the former didn't work) command to terminate the application.

  8. Feb 10, 2012 · The shell command and any arguments to that command appear as numbered shell variables: $0 has the string value of the command itself, something like script, ./script, /home/user/bin/script or whatever. Any arguments appear as "$1", "$2", "$3" and so on. The count of arguments is in the shell variable "$#".

  9. Dec 26, 2014 · Shell variables and environment variables. An environment variable is available to exec()-ed child processes (as a copy; if parent process change the variable, the child environment is not updated). A non-environment variable is only available to the current running shell and fork()-ed subshells.

  10. Feb 27, 2015 · @orion But in shell, there aren’t really booleans; false and true are commands that always fail or always succeed, respectively. && and || execution is based on exit status, not on boolean value, but it is quite analogous to “and” and “or” in other programming languages.

  1. People also search for