Computing.Net > Forums > Programming > ksh script variable problem

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.

ksh script variable problem

Reply to Message Icon

Name: jgt157
Date: March 31, 2009 at 09:09:29 Pacific
OS: AIX 6.1
Subcategory: General
Comment:

I'm trying to combine two variables with an underscore in between and assign it to a new variable and I don't remember how to do it. Here's the script:

#!/bin/ksh
#Display the date and hostname

DATEFIELD=$(date +%m%d%y)
print -n "Input hostname: "; read HOSTNAME; print ""
print $DATEFIELD
print $HOSTNAME

PATHNAME=$($HOSTNAME && _ && $DATE)
print -n $PATHNAME

exit 0

Any help would be appreciated. Thanks...



Sponsored Link
Ads by Google

Response Number 1
Name: nails
Date: March 31, 2009 at 10:25:13 Pacific
Reply:

Is this what you are asking for:

#!/bin/ksh
#Display the date and hostname

DATEFIELD=$(date +%m%d%y)
print -n "Input hostname: "; read HOSTNAME; print ""
print $DATEFIELD
print $HOSTNAME

# double quotes are probably optional
PATHNAME="${HOSTNAME}_${DATEFIELD}"
echo $PATHNAME

exit 0


0

Response Number 2
Name: jgt157
Date: March 31, 2009 at 10:40:55 Pacific
Reply:

That was it!. Thanks!


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: ksh script variable problem

KSH scripting help - newbie www.computing.net/answers/programming/ksh-scripting-help-newbie/14108.html

stdin problems using ksh and java www.computing.net/answers/programming/stdin-problems-using-ksh-and-java/4035.html

vb script path problem (wildcard) www.computing.net/answers/programming/vb-script-path-problem-wildcard/14582.html