Sponsored Content
Full Discussion: Meaning of '$#' in Unix
Top Forums Shell Programming and Scripting Meaning of '$#' in Unix Post 302502800 by fhernu on Wednesday 9th of March 2011 01:35:58 AM
Old 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

Meaning of unix-rt ldp file type

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

Meaning of ; in UNIX file?

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

Oot: Level 2 Unix Support? meaning

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

What is the meaning of $_

Hi, Can somebody tell the usage of "$_" cd $_ ? and ls $_ ? (4 Replies)
Discussion started by: giri_luck
4 Replies

5. Shell Programming and Scripting

Meaning of each term in stty -a in unix

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

meaning of <<!

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

UNIX Script - snipet meaning?

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

&& meaning in UNIX

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

What is the meaning of ## in UNIX shell script?

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

Meaning of $1^

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
sysdef(1M)																sysdef(1M)

NAME
sysdef - display system definition SYNOPSIS
[kernel [master]] DESCRIPTION
Note: will not be supported in future releases of HP-UX (refer to section below). So users are advised to use the kctune(1M) utility which provides additional information on kernel tunable parameters. The command analyzes the currently running system and reports on its tunable configuration parameters. kernel and master are not used, but can be specified for standards compliance. For each configuration parameter, the following information is printed: The name and description of the parameter. The current value of the parameter. The value of the parameter at boot time, if different from the current value. The minimum allowed value of the parameter, if any. The maximum allowed value of the parameter, if any. Where appropriate, the units by which the parameter is measured. Flags that further describe the parameter. The following flag is defined: Parameter can be modified without rebooting. WARNINGS
Users of must not rely on the exact field widths and spacing of its output, as these will vary depending on the system, the release of HP- UX, and the data to be displayed. is provided for compatibility purposes only and is no longer maintained since being marked for obsolescence in a future HP-UX release. The output from is known to be incorrect when reporting values for some tunable parameters such as and SEE ALSO
kctune(1M). TO BE OBSOLETED sysdef(1M)
All times are GMT -4. The time now is 08:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy