Sending output to a file - Merged from duplicate thread

Hi All,

read dif
echo `date +%Y%m%d`|./add $dif|./fmtdt %mon%dd

The above script is for adding days to current date to find the new date. This script divides the current date into 20060220(YYYYMMDD) format and pass this output to add script. The add script will add the days to the current date and will produce output in the YYYYMMDD format 20060225.The fmtdt will produce the output in the Mon dd(Feb 20) format.

The output will be Feb 25 (if input is 5 and current date is Feb 20)

The output of the above script should be passed to a variable and the variable should be printed like /Feb 25/ (add this front and back print)

Question

  1. How to pass the output to a variable (ex ouput: Feb 20)

  2. Then how to print the variable in the following format /Feb 20/

I am new to Shell scripting.Please help me.Please answer ASAP(URGENT).

Thanks in advance.

Note:

Is there anyway to pass this output to file and cat that file and pass this to a variable.

I did like this

echo `date +%Y%m%d`|./add $dif|./fmtdt %mon%dd > date_file (Succeeded-The file is created with output)

a= cat date_file(Failed to assign the value to a file

I succeeded in passing the output to file and cat that file .But failed to assign that value to a Variable.Please Guide me

Hi All,

read dif
echo `date +%Y%m%d`|./add $dif|./fmtdt %mon%dd

The above script is for adding days to current date to find the new date. This script divides the current date into 20060220(YYYYMMDD) format and pass this output to add script. The add script will add the days to the current date and will produce output in the YYYYMMDD format 20060225.The fmtdt will produce the output in the Mon dd(Feb 20) format.

The output will be Feb 25 (if input is 5 and current date is Feb 20)

The output of the above script should be passed to a variable and the variable should be printed like /Feb 25/ (add this front and back print)

Question

  1. How to pass the output to a variable (ex ouput: Feb 20)

  2. Then how to print the variable in the following format /Feb 20/

I am new to Shell scripting.Please help me.Please answer ASAP(URGENT).

Thanks in advance.

Note:

Is there anyway to pass this output to file and cat that file and pass this to a variable.

I did like this

echo `date +%Y%m%d`|./add $dif|./fmtdt %mon%dd > date_file (Succeeded-The file is created with output)

a= cat date_file(Failed to assign the value to a file

I succeeded in passing the output to file and cat that file .But failed to assign that value to a Variable.Please Guide me

Try:

a=`cat date_file`

This will assign the file contents to a