LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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, 09:01 AM   #1
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 707

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, 09: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, 12:01 PM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
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, 06:18 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

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


Reply



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

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

All times are GMT -5. The time now is 08:18 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
Open Source Consulting | Domain Registration