LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-19-2009, 02:21 AM   #1
ZAMO
Member
 
Registered: Mar 2007
Distribution: Redhat &CentOS
Posts: 598

Rep: Reputation: 30
bash scripting


Hi all,


I need to know the meaning of a call in for loop?

Code:
for i in "$@" ; do
 echo $i
done
any idea? Got struck in an old script. What I want is, what is mean by
Code:
for i in "$@"
Thanks
 
Old 01-19-2009, 02:25 AM   #2
eco
Member
 
Registered: May 2006
Location: BE
Distribution: Debian/Gentoo
Posts: 412

Rep: Reputation: 48
Quote:
@ Expands to the positional parameters, starting from one. When
the expansion occurs within double quotes, each parameter
expands to a separate word. That is, "$@" is equivalent to "$1"
"$2" ... If the double-quoted expansion occurs within a word,
the expansion of the first parameter is joined with the
beginning part of the original word, and the expansion of the
last parameter is joined with the last part of the original
word. When there are no positional parameters, "$@" and $@
expand to nothing (i.e., they are removed).
Streigh out of man bash


... and to make things clearer:

Code:
#!/bin/bash

for i in "$@"; do
        echo $i
done
Code:
# . ./test.sh one two three
one
two
three

Last edited by eco; 01-19-2009 at 02:30 AM.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading a bash variable in bash scripting problem freeindy Programming 3 11-27-2008 02:29 AM
bash scripting Springs Linux - Newbie 7 04-17-2008 05:14 AM
bash scripting stu_mueller Slackware 4 04-15-2008 02:09 PM
Bash scripting vinoth.ilango Solaris / OpenSolaris 6 10-29-2004 04:41 AM
About bash scripting pazvant Programming 3 10-20-2003 11:12 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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