LinuxQuestions.org
Help answer threads with 0 replies.
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 12-18-2007, 01:46 PM   #1
danielj28
LQ Newbie
 
Registered: Nov 2007
Posts: 2

Rep: Reputation: 0
What does the $@ represent in a bash script?


I'm new to reading (and writing) bash scripts and I can't find any documentation for what the $@ parameter/variable represents and what value it receives. Please advise. Thanks.
 
Old 12-18-2007, 02:18 PM   #2
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Quote:
Originally Posted by man bash
@ 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 orig-
inal 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).
It means each argument supplied to the script from the command line:
Code:
pwc101@linux:> ./myscript argument_1 argument_2
$@ represents argument_1 and argument_2 in that example, which can be individually referenced as $1 and $2.

See http://db.ilug-bom.org.in/Documentat...es.html#APPREF for more info.
 
Old 12-18-2007, 06:37 PM   #3
danielj28
LQ Newbie
 
Registered: Nov 2007
Posts: 2

Original Poster
Rep: Reputation: 0
Thanks

for the help!
 
Old 12-18-2007, 06:51 PM   #4
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
On most distributions the info command (in a terminal window) may be used to display information about a command. Did you try info bash?

If you're not familiar with the info command, try info info for an explanation.
 
Old 12-18-2007, 10:56 PM   #5
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,355

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
The nice version of the manual: http://www.tldp.org/LDP/abs/html/int...es.html#APPREF
 
  


Reply

Tags
bash, syntax


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
passing variable from bash to perl in a bash script quadmore Programming 6 02-21-2011 04:11 AM
set variables in a bash script; ansi PS1 color script donnied Programming 4 11-21-2007 11:33 AM
Bash script to create bash script jag7720 Programming 10 09-10-2007 07:01 PM
[bash] having trouble debugging this bash script. jons Programming 4 02-08-2007 06:51 AM
send automatic input to a script called by another script in bash programming jorgecab Programming 2 04-01-2004 12:20 AM

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

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