03-09-2011
This means the number of parameters (values) given to the script.
This small example will help you to understand :
Create the scritpt
test.sh containing the following lines
echo "1st parameter : $1"
echo "2nd parameter : $2"
echo "3rd parameter : $3"
echo "Number of parameters: $#"
If you execute ./test.sh A B C
The output will be :
1st parameter : A
2nd parameter : B
3rd parameter : C
Number of parameters: 3
If now you execute ./test.sh A B
The output will be :
1st parameter : A
2nd parameter : B
3rd parameter :
Number of parameters: 2
Coming back to your script :
if test $# -eq 1 checks that one parameter is given to the script during its execution. Please notice this doesn't check the content of this parameter.
This User Gave Thanks to fhernu For This Post:
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hello
I was wondering what this file type means...
assuming it is some type of data.
Is ldp - Linux Doc Program?
What type of program would be used to read or interpret this file type?
As you can see I'm not a developer, and don't review these
types of files. But would like to view... (1 Reply)
Discussion started by: jfmrts
1 Replies
2. UNIX for Dummies Questions & Answers
Hello.
I'm looking at a file that has a ; at the beginning of certain lines. Could someone please tell me what that means? Is it a comment? Is it an execute?
Thank You (1 Reply)
Discussion started by: willdaw3
1 Replies
3. UNIX for Dummies Questions & Answers
Hi all,
I am sorry, I know this is not correct forum/silly question (usually this is requirement in some vacancies), but i hope someone can explain to me, what is the meaning of :
SUN Tier 3 Support
Tier 3 Application Installation
Level 2 Solaris
Level 2 AD MOM + DBA
Thank you. (0 Replies)
Discussion started by: blesets
0 Replies
4. Shell Programming and Scripting
Hi,
Can somebody tell the usage of "$_"
cd $_ ?
and ls $_ ? (4 Replies)
Discussion started by: giri_luck
4 Replies
5. Shell Programming and Scripting
Hi,
Can someone help me with the meaning of each term in the below command in unix:
stty-aRegds,
I have searched google for a lot for this, but didnt get any success in this.
Kunwar (2 Replies)
Discussion started by: kunwar
2 Replies
6. UNIX for Dummies Questions & Answers
Hi all,
I wanna know the meaning of the last word "<<! "
sudo su - user <<!
please help on this !!!! (1 Reply)
Discussion started by: sudharson
1 Replies
7. UNIX for Dummies Questions & Answers
What would the below code snippet mean?
my ($_configParam, $_paramValue) = split(/\s*=\s*/, $_, 2);
$configParamHash{$_configParam} = $_paramValue; (2 Replies)
Discussion started by: MaKha
2 Replies
8. UNIX for Beginners Questions & Answers
Hi Team,
I know that "&" holds the result of current pattern match.
But what does "&&" means and its use please?
Thanks & Regards,
Batta Archana (6 Replies)
Discussion started by: Archana Batta
6 Replies
9. Shell Programming and Scripting
Hi All,
I am new to unix shell scripting and I was documenting one of the unix script and encountered below statements -
for ii in `ls -1rt /oracle/admin/MARSCOPY/ext_files/fpm-ifpm/*.small.txt | tail -1 | awk '{print $1}'`
do
smallssim=${ii##/oracle/admin/MARSCOPY/ext_files/fpm-ifpm/}... (2 Replies)
Discussion started by: shuklajayb4
2 Replies
10. Shell Programming and Scripting
Hello everyone,
I'm looking for the meaning of this expression, as I don't understand it quite clearly : $1^
What do you think it could be?
I thought either:
- match lines starting with argument 1 but it should be ^$1
- turn line around : word becomes drow
Thanks in advance for your... (4 Replies)
Discussion started by: bibelo
4 Replies
LEARN ABOUT MOJAVE
xml::parser::style::stream5.18
Parser::Style::Stream(3) User Contributed Perl Documentation Parser::Style::Stream(3)
NAME
XML::Parser::Style::Stream - Stream style for XML::Parser
SYNOPSIS
use XML::Parser;
my $p = XML::Parser->new(Style => 'Stream', Pkg => 'MySubs');
$p->parsefile('foo.xml');
{
package MySubs;
sub StartTag {
my ($e, $name) = @_;
# do something with start tags
}
sub EndTag {
my ($e, $name) = @_;
# do something with end tags
}
sub Characters {
my ($e, $data) = @_;
# do something with text nodes
}
}
DESCRIPTION
This style uses the Pkg option to find subs in a given package to call for each event. If none of the subs that this style looks for is
there, then the effect of parsing with this style is to print a canonical copy of the document without comments or declarations. All the
subs receive as their 1st parameter the Expat instance for the document they're parsing.
It looks for the following routines:
o StartDocument
Called at the start of the parse .
o StartTag
Called for every start tag with a second parameter of the element type. The $_ variable will contain a copy of the tag and the %_
variable will contain attribute values supplied for that element.
o EndTag
Called for every end tag with a second parameter of the element type. The $_ variable will contain a copy of the end tag.
o Text
Called just before start or end tags with accumulated non-markup text in the $_ variable.
o PI
Called for processing instructions. The $_ variable will contain a copy of the PI and the target and data are sent as 2nd and 3rd
parameters respectively.
o EndDocument
Called at conclusion of the parse.
perl v5.18.2 2011-05-24 Parser::Style::Stream(3)