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 11-17-2009, 12: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, 01:00 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
"$*" 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 01: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 04:26 AM
what is the difference? mjm70 Mandriva 1 06-14-2005 11:04 AM
What is the difference between WE/WM and DE? eBopBob Linux - Newbie 3 12-12-2004 06:26 AM
What's the difference between dominionlife Linux - Newbie 5 10-18-2004 08:26 PM
Difference? Jongi Linux - Newbie 4 08-22-2003 02:21 AM

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

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