Computing.Net > Forums > Unix > help with script - I am new to Unix

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

help with script - I am new to Unix

Reply to Message Icon

Name: sammyboy
Date: December 4, 2001 at 13:11:33 Pacific
Comment:

I am new to Unix and I am trying to write a Bourne shell script. I have 2 questions:

1. One of the command line parms for the script needs to be converted to upper case within the script, how do I do this?
I tried tr 'a-z' 'A-Z'. It works fine on the command line but not when I want to pass $1 to change it to upper case in my script

2. I am reading 2 parms from the command line, and I want to set a default if no parms are entered. How do I do this?
will this work?
case $# in
1)days=$1;;
0)days=2;;
2)domain=$2;;
0)domain=mydomain;;
esac



Sponsored Link
Ads by Google

Response Number 1
Name: Jo
Date: December 5, 2001 at 09:55:27 Pacific
Reply:

1) Try this:
string=`echo $1 | tr '[a-z]' '[A-Z]'`

2)
# Start of sample-1
case $# in
  0) days=default; domain=default;;
  1) days=$1; domain=default;;
  2) days=$1; domain=$2;;
esac
# End of sample-1, start of sample-2
days=default;
domain=default;
case $# in
  1) days=$1;;
  2) days=$1; domain=$2;;
esac
# End of sample-2


0
Reply to Message Icon

Related Posts

See More


cat vs. read printer manager



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: help with script - I am new to Unix

I need a help from you. i am new to shell scr www.computing.net/answers/unix/i-need-a-help-from-you-i-am-new-to-shell-scr/8514.html

Help with UNIX Question www.computing.net/answers/unix/help-with-unix-question/2465.html

Need help with sorting a file www.computing.net/answers/unix/need-help-with-sorting-a-file/6971.html