You are not logged in.

#1 2007-01-22 15:03:00

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,896
Website

bash number of command line args....

Hi,

Is there a way in bash to get number of command line args ...

atm I am using $1 but of course if you pass a command like uname -a you need two?

wondered if there is a $<foo> that ill give number of args passed?

EDIT looks like '$#' emmmm lets see....


Mr Green

Offline

#2 2007-01-22 15:37:35

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,896
Website

Re: bash number of command line args....

ok so I have numbers of args how do I pass them to script

want to pass command uname -a > /tmp/cmd

being 2 args ???


Mr Green

Offline

#3 2007-01-22 15:57:09

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: bash number of command line args....

$# does what you want.  Also, check this out here:
http://tldp.org/LDP/abs/html/

Offline

#4 2007-01-22 16:18:25

Mr Green
Forum Fellow
From: U.K.
Registered: 2003-12-21
Posts: 5,896
Website

Re: bash number of command line args....

woah!!! ok thanks ..... $# gives me number of args ... will check it out

$1 $2 > /tmp/cmd

messy way.....


Mr Green

Offline

Board footer

Powered by FluxBB