LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-22-2011, 12:05 PM   #1
mattgeorge
LQ Newbie
 
Registered: Jun 2011
Posts: 4

Rep: Reputation: Disabled
$# in shell scripts


Hi,
can anyone tell me what the $# represents in UNIX?

i know that $1, $2 etc represents the 1st and 2 nd parameters or std inputs.
 
Old 06-22-2011, 12:08 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
It is the number of positional parameters.
 
1 members found this post helpful.
Old 06-22-2011, 12:43 PM   #3
SL00b
Member
 
Registered: Feb 2011
Location: LA, US
Distribution: SLES
Posts: 375

Rep: Reputation: 112Reputation: 112
Quote:
Originally Posted by mattgeorge View Post
Hi,
can anyone tell me what the $# represents in UNIX?

i know that $1, $2 etc represents the 1st and 2 nd parameters or std inputs.
You just answered your own question, so maybe you could explain your confusion further.
 
Old 06-22-2011, 12:44 PM   #4
mattgeorge
LQ Newbie
 
Registered: Jun 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
thanks colucix,
made anayzing the script much easier !!
 
Old 06-22-2011, 12:48 PM   #5
mattgeorge
LQ Newbie
 
Registered: Jun 2011
Posts: 4

Original Poster
Rep: Reputation: Disabled
@ SL00b : i thought tht $# might be related to the outcome of some previous command... didnt relate it to the number of positional parameters.. now the tube light has lit up .. nd makes my life easier.. thnx
 
Old 06-22-2011, 01:33 PM   #6
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720Reputation: 720
Quote:
Originally Posted by mattgeorge View Post
@ SL00b : i thought tht $# might be related to the outcome of some previous command...
In case you don't know, "$?" contains the exit code of the previous command.

Also, if the thread is solved, mark it as solved.
 
1 members found this post helpful.
Old 06-22-2011, 07:38 PM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
On a related note you might want to lookup $* and $@
http://rute.2038bug.com/index.html.gz
http://tldp.org/LDP/Bash-Beginners-G...tml/index.html
http://www.tldp.org/LDP/abs/html/
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
New at shell scripts -- OnlySolitaire Programming 13 02-12-2011 05:59 AM
How to ssh from a shell script ? For ppl who can write shell scripts. thefountainhead100 Programming 14 10-22-2008 07:24 AM
Shell scripts...then some. Freestone Programming 3 04-23-2006 01:13 PM
Shell scripts j0hn0n1 Linux - Software 1 01-03-2003 04:11 PM
Need Help with Shell Scripts!!!!!!!!!!! vicsharps Linux - Newbie 3 03-07-2002 10:05 PM


All times are GMT -5. The time now is 12:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration