Computing.Net > Forums > Linux > Shell Script - help

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.

Shell Script - help

Reply to Message Icon

Name: Samuel R Ragunaat
Date: July 10, 2003 at 06:09:02 Pacific
OS: Linux
CPU/Ram: AMD
Comment:

hi, I want to write a shell script which will execute some commnds in the script and create a resulted variable with all the results.
e.g.
-----------------
#!/bin/bash
year = 'date +%Y'
month = 'date +%M'

echo $year
echo $month

MY = $year_$month
echo MY


actually i expected $year to give "2003"
It's not working ...:(

Can u help me !!



Sponsored Link
Ads by Google

Response Number 1
Name: David Perry
Date: July 10, 2003 at 12:56:21 Pacific
Reply:

You cannot have spaces between the variable name, the equals sign or the equals sign and the value.
You need back tick marks and not single quotes around the date portion.

year=`date +%Y`
MY=`echo ${year}_$month`
echo $MY


0

Response Number 2
Name: Samuel R Ragunaat
Date: July 10, 2003 at 21:35:37 Pacific
Reply:

Thanks a lot David Perry. It worked. Actually I used back tick but had space. Your respose help me to solve this issue.

Thanks again!


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 Linux Forum Home


Sponsored links

Ads by Google


Results for: Shell Script - help

advanced shell script help www.computing.net/answers/linux/advanced-shell-script-help/17749.html

shell script help www.computing.net/answers/linux/shell-script-help/15420.html

begginner shell script help ASAP! www.computing.net/answers/linux/begginner-shell-script-help-asap/18683.html