AnswerPls

What is $1 and $2 in shell script?

Asked by Belinda Horton on September 08, 2021

Categories: Technology and computing Operating systems


Rating: 4.6/5 (60 votes)

what is $1. $1 is the first commandline argument. If you run ./asdf.sh a b c d e, then $1 will be a, $2 will be b, etc. In shells with functions, $1 may serve as the first function parameter, and soforth.

How do you find out what's your shell? Remember $ returns the PID (process identification number) of the current process, and the current process is your_shell. So running a ps on that number displays a process status listing of your_shell. In that listing, you will find the name of your shell (look for CMD column).

Who wrote bash? Richard Stallman and a group oflike-minded developers were writing all the features of Unix with a license that is freely available under the GNU license. One of those developers was tasked with making a shell. That developer was Brian Fox.

What does mean in bash? Bash is a command language interpreter. It is widely available on various operating systems and is a default command interpreter on most GNU/Linux systems. The name is an acronym for the 'Bourne-Again SHell'. Shell. Shell is a macroprocessor which allows for an interactive or non-interactive command execution.

How do you pass arguments in bash? To pass any number of arguments to the bash function simply put them right after the function's name, separated by a space. It is agood practice to double-quote the arguments to avoid misparsing of an argument with spaces in it. The passed parameters are $1 , $2 , $3 …