Sponsored Content
Top Forums UNIX for Dummies Questions & Answers How to check arguments in shell??? Post 302761413 by tukuyomi on Friday 25th of January 2013 03:00:44 PM
Old 01-25-2013
This should fulfill your requirements
Code:
#!/bin/sh

if [ "$#" -eq 1 ]; then
	path="$1"
else
	file="$1"
	path="$2"
fi

exit 0

 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Arguments to a shell program

Hi List, Is it possible to pass one argument to a shell program eg) there is a shell program abc which takes one arguments abc one Due to some reasons I pass abc one two Now one,two must be considered as "one" argument to the shell programs. Any suggestions,hints are welcome. ... (3 Replies)
Discussion started by: csvenkata
3 Replies

2. Shell Programming and Scripting

Shell script with arguments

Hi All, I need some help/ideas in coming up with a shell script. Basically, the script should install 1 or 2 or 3 packages based on the input arguments. For example, if I type in pkgscript.sh a1 a2 a3, it should install all the 3 scripts and pkgscript.sh a1 should install only a1. If a... (3 Replies)
Discussion started by: sankar6254
3 Replies

3. Shell Programming and Scripting

Bash Shell - # of arguments

Hi!, How can I check the number of arguments passed from the shell in a bash shell ? (1 Reply)
Discussion started by: DNAx86
1 Replies

4. Programming

read arguments from shell

I have to write a C program using sys call (read, no fread) to read from shell all the parameters, without know how many are them. I tryed in some ways, but I have no success. Any Idea? Can I use read to read from stdin? (1 Reply)
Discussion started by: DNAx86
1 Replies

5. Shell Programming and Scripting

Check if passed arguments is users

i want to check passed arguments one by one and if it is user print home director of that user (3 Replies)
Discussion started by: testman84
3 Replies

6. Shell Programming and Scripting

Using arguments in Shell script

Hello, I have to make a shell script doing that : the program tests if there is an argument, if there is it checks whether this is a directory or not, If it is it opens it. for any .c file in the directory it prints 2 lines in the screen : the dependence line of the .o and compiler commend... (1 Reply)
Discussion started by: dekl
1 Replies

7. Homework & Coursework Questions

Shell Scripting with Arguments

1. The problem statement, all variables and given/known data: Problem 1: I need to create a shell script the takes three arguments and echo's out "There once was a ____that____who like to_____" The arguments go where the blanks are. Problemt 2: -Do an LS and store the... (4 Replies)
Discussion started by: dw15
4 Replies

8. Shell Programming and Scripting

sub arguments to shell script

Hi, I have a shell script, when run it i get a prompt to enter arguments say 1 for doing my next task otherwise q for quit. What I am trying to do is run the shell script with the argument passed in however it does not seem to work. This is what I did ./test.sh 1 Instead it printed the line... (6 Replies)
Discussion started by: aqua9
6 Replies

9. Shell Programming and Scripting

Shell scripting with passing arguments

Hi All, I am using the script for creating local queue and passing the arguments while running the script as below n=0 while do e=`expr $n + 3` echo 'DEFINE QL('$e') MAXDEPTH('$6') MAXMSGL('$7') DEFPSIST('$8') '$9'' | /apps/mqm_opt/bin/runmqsc $2 n=`expr $n + 1` done Running the... (5 Replies)
Discussion started by: Anusha M
5 Replies

10. UNIX for Beginners Questions & Answers

Shell script file check throws [: too many arguments

While I am trying to check the filename/s in IF statement of a shell script (RedHat Linux 6) I am getting below error: File check: filename_time2=`date --date='yesterday' +%Y-%m-%d` cd /location/of/the/files/to/copy if then cp server.log-$filename_time2* ../archive/new... (5 Replies)
Discussion started by: Dip
5 Replies
Locale::Codes::LangVar(3pm)				 Perl Programmers Reference Guide			       Locale::Codes::LangVar(3pm)

NAME
Locale::Codes::LangVar - standard codes for language variation identification SYNOPSIS
use Locale::Codes::LangVar; $lvar = code2langvar('acm'); # $lvar gets 'Mesopotamian Arabic' $code = langvar2code('Mesopotamian Arabic'); # $code gets 'acm' @codes = all_langvar_codes(); @names = all_langvar_names(); DESCRIPTION
The "Locale::Codes::LangVar" module provides access to standard codes used for identifying language variations, such as those as defined in the IANA language registry. Most of the routines take an optional additional argument which specifies the code set to use. If not specified, the default IANA language registry codes will be used. SUPPORTED CODE SETS
There are several different code sets you can use for identifying language variations. A code set may be specified using either a name, or a constant that is automatically exported by this module. For example, the two are equivalent: $lvar = code2langvar('en','alpha-2'); $lvar = code2langvar('en',LOCALE_CODE_ALPHA_2); The codesets currently supported are: alpha This is the set of alphanumeric codes from the IANA language registry, such as 'arevela' for Eastern Armenian. This code set is identified with the symbol "LOCALE_LANGVAR_ALPHA". This is the default code set. ROUTINES
code2langvar ( CODE [,CODESET] ) langvar2code ( NAME [,CODESET] ) langvar_code2code ( CODE ,CODESET ,CODESET2 ) all_langvar_codes ( [CODESET] ) all_langvar_names ( [CODESET] ) Locale::Codes::LangVar::rename_langvar ( CODE ,NEW_NAME [,CODESET] ) Locale::Codes::LangVar::add_langvar ( CODE ,NAME [,CODESET] ) Locale::Codes::LangVar::delete_langvar ( CODE [,CODESET] ) Locale::Codes::LangVar::add_langvar_alias ( NAME ,NEW_NAME ) Locale::Codes::LangVar::delete_langvar_alias ( NAME ) Locale::Codes::LangVar::rename_langvar_code ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangVar::add_langvar_code_alias ( CODE ,NEW_CODE [,CODESET] ) Locale::Codes::LangVar::delete_langvar_code_alias ( CODE [,CODESET] ) These routines are all documented in the Locale::Codes::API man page. SEE ALSO
Locale::Codes The Locale-Codes distribution. Locale::Codes::API The list of functions supported by this module. http://www.iana.org/assignments/language-subtag-registry The IANA language subtag registry. AUTHOR
See Locale::Codes for full author history. Currently maintained by Sullivan Beck (sbeck@cpan.org). COPYRIGHT
Copyright (c) 2011-2012 Sullivan Beck This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.16.2 2012-10-11 Locale::Codes::LangVar(3pm)
All times are GMT -4. The time now is 03:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy