[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-bash] View Positional Parameters of Commands

From: Michael Convey
Subject: [Help-bash] View Positional Parameters of Commands
Date: Tue, 28 Jul 2015 07:58:08 -0700

I'm trying to understand positional parameters. If I run the the following

ls -al

echo $0 should equal ls
echo $1 should equal -a
echo $2 should equal -l

However, no matter which command I run, echo $0 always equals "bash" and
$1, $2, etc. are empty. I suspect this is because my original command is
being run in a subshell and the echo commands are being run in a different
subshell, which is invoked by parent shell as the 'bash' command. So, I
tried to run these commands using 'source command', to run everything in
the parent shell. However, I get the following error:

bash: source: /usr/bin/command: cannot execute binary file

So I tried the following:

ls -al; echo $0; echo $1

But, I get the same results. What is the best way to do what I'm trying to
accomplish -- view positional parameters of commands I run?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]