LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 10-26-2009, 10:01 AM   #1
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Rep: Reputation: 55
confused with $* and $@


Hi all...

I am not able to distinguish between $* and $@, both will store the list of positional parameters...

echo $*
echo $@

are giving me same results even when command line arguments are quoted....

Help me please

Thanks in advnace....
 
Old 10-26-2009, 10:06 AM   #2
avijitp
Member
 
Registered: May 2005
Location: India
Distribution: FC11, Debian/Ubuntu, RHEL, Solaris, AIX, HP-UX
Posts: 161

Rep: Reputation: 32
Googled and found this:

Code:
$* command-line arguments as one string 

$@ command-line arguments as list of strings (useful for writing wrapper shell scripts that just add one argument)
 
Old 10-26-2009, 01:01 PM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Quote:
Originally Posted by vinaytp View Post
giving me same results even when command line arguments are quoted
This illustrates the difference, initially with what you may have tried with apparently the same results for each (they're not the same but you can't see the difference) and then using them in a way that shows the difference
Code:
c:~$ set 'a b' c
c:~$ echo "$*"
a b c
c:~$ echo "$@"
a b c
c:~$ for var in "$@"; do echo $var; done
a b
c
c:~$ for var in "$*"; do echo $var; done
a b c
c:~$
 
Old 10-26-2009, 07:18 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
http://tldp.org/LDP/Bash-Beginners-G...ml#table_03_01
 
  


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
thoroughly confused mconnors Linux - General 10 05-09-2008 03:18 PM
Confused nay Very Confused chrystlenight SUSE / openSUSE 3 08-28-2007 06:57 PM
Confused! wak Linux - Newbie 6 03-14-2007 01:09 PM
Confused! javamdk Linux - Networking 2 03-19-2005 01:32 AM
IM Confused, Again? Winux Linux - Newbie 3 04-08-2003 04:40 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:53 PM.

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