LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 11-17-2009, 01:25 AM   #1
shibu_sp
Member
 
Registered: Aug 2007
Posts: 57

Rep: Reputation: 15
difference between $@ and $*


Dear all

what is difference between $@ and $* in UNIX Shell script

Thanks and regards
Shibu
 
Old 11-17-2009, 02:00 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
"$*" outputs all parameters ($1, $2, etc) as a single unit. For that reason it's supposed to always be quoted, or else bash's word separation function will also affect the output.

"$@" outputs all parameters as individual items, that is, loops and things like that will treat each item as a separate unit, whether they have spaces in them or not. Note that you still have to quote the variable to prevent word separation though.

The same pattern works in array elements as well.

The section on positional parameters on this page details the behavior:
http://www.tldp.org/LDP/abs/html/internalvariables.html

Last edited by David the H.; 11-17-2009 at 02:02 AM.
 
  


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
shell script to find the difference betwwn two file and place the difference to other kittunot4u Linux - General 3 07-19-2010 05:26 AM
what is the difference? mjm70 Mandriva 1 06-14-2005 12:04 PM
What is the difference between WE/WM and DE? eBopBob Linux - Newbie 3 12-12-2004 07:26 AM
What's the difference between dominionlife Linux - Newbie 5 10-18-2004 09:26 PM
Difference? Jongi Linux - Newbie 4 08-22-2003 03:21 AM


All times are GMT -5. The time now is 02: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