LinuxQuestions.org
Help answer threads with 0 replies.
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 02-16-2010, 06:00 AM   #1
lipun4u
Member
 
Registered: Sep 2008
Location: Mumbai, india
Distribution: ubuntu and hp-unix
Posts: 118

Rep: Reputation: 15
$* and $@


Consider the following code..

Code:
      1 #!/bin/bash
      2
      3 count=1
      4 for param in "$*"
      5 do
      6     echo "\$* Parameter #$count = $param"
      7     count=$[ $count + 1 ]
      8 done
      9
     10 count=1
     11 for param in "$@"
     12 do
     13     echo "\$@ Parameter #$count = $param"
     14     count=$[ $count + 1 ]
     15 done

Here $* variable takes all of the parameters supplied on the command line as a single word and $@ variable takes all the parameters supplied on the command line as separate words in the same string.


Quote:
[user31@FEDORA ~]$ ./last1.sh asit qutub sunil chusa ruplina
The last parameter is 5
The last parameter is ruplina
But why the op is same as required in my system ??

My system is
Quote:
[user31@FEDORA ~]$ uname -a
Linux FEDORA 2.6.9-1.667 #1 Tue Nov 2 14:41:25 EST 2004 i686 i686 i386 GNU/Linux

Last edited by lipun4u; 02-16-2010 at 06:01 AM.
 
Old 02-16-2010, 06:31 AM   #2
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
I don't understand your question. The script is behaving exactly as expected.
 
  


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 > Linux Forums > Linux - Newbie

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