LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-22-2013, 05:20 PM   #1
reza_zah1991
Member
 
Registered: Mar 2013
Location: Qom , Iran
Distribution: opensuse,lubuntu
Posts: 32

Rep: Reputation: Disabled
Thumbs up $* and $@


hi folks

what is different between $* and $@ in arrays or function input Argument??

array[@]=array[*]

tnx
 
Old 07-22-2013, 08:32 PM   #2
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
The main every-day difference is with quoting. "$*" will give you a single string, whereas "$@" will give you one string per array element.
Code:
$ star_style() { for i in "$*"; do echo "$i"; done; }
$ at_style()   { for i in "$@"; do echo "$i"; done; }
$ star_style 1 2 3
1 2 3
$ at_style 1 2 3
1
2
3
Kevin Barry

Last edited by ta0kira; 07-22-2013 at 08:36 PM.
 
1 members found this post helpful.
Old 07-23-2013, 02:47 AM   #3
reza_zah1991
Member
 
Registered: Mar 2013
Location: Qom , Iran
Distribution: opensuse,lubuntu
Posts: 32

Original Poster
Rep: Reputation: Disabled
tnx man
 
  


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



LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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