- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Query on Command line argument
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2011 12:34 AM
07-19-2011 12:34 AM
Query on Command line argument
Hi Experts,
I am newbie to scripting. While I come through some docs, I crossed one topic called 'Arguments to Shell Programs". I am not able to understand that at all. If you could make me understand in a way, it would be highly appreciated.
$0 - The command name
$1 - The first argument
$2 - The second argument
.
.
$9 - The ninth argument
$# - The number of command line arguments
$*
$n
Please explain about above also.
Thanks in advance
Rgds...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2011 12:54 AM
07-19-2011 12:54 AM
Re: Query on Command line argument
I guess google is broken again then?
There are so many shell script tutorials out there on the internet, any reply here is really just repetition
http://www.freeos.com/guides/lsst/ch02sec13.html
Seems like a pretty simple intro to command line arguments
I am an HPE Employee

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2011 03:51 AM
07-19-2011 03:51 AM
Re: Query on Command line argument
Why not try it out for yourself?
$ your-script.sh p1 p2 p3 p4 p5 p6 p7
In your-script.sh:
echo "$0: args: $@"
echo "$0 has $# args"
echo "$1"
echo "$2"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-19-2011 04:33 AM
07-19-2011 04:33 AM
Re: Query on Command line argument
Hi:
The easiest way to learn is to read and *write*. Your scripts can be as simple as Dennis suggested. The important part is to practice. Where possible, run code that you see to discover how and why it works. An excellent source of good scripts and tutorials (including one germane to your question here) is:
...http://www.shelldorado.com/goodcoding/cmdargs.htmland, specifically to this question:
Regards!
...JRF...