Sending output to a file - Merged from duplicate thread


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sending output to a file - Merged from duplicate thread
# 1  
Old 02-20-2006
Sending output of a script to a varible

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

Last edited by muthu_nix; 02-20-2006 at 10:53 AM..
# 2  
Old 02-20-2006
Sending output to a file

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
# 3  
Old 02-20-2006
Try:

a=`cat date_file`

This will assign the file contents to a
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell Script to Read the given file contents into a merged one file

Like to have shell script to Read the given file contents into a merged one file with header of path+file name followed by file contents into a single output file. While reading and merging the file contents into a single file, Like to keep the format of the source file. ... (4 Replies)
Discussion started by: Siva SQL
4 Replies

2. Shell Programming and Scripting

Script for getting the file merged

Hi, I have two files separated by bars at each line File 1 : A|4356|13456|23456 A|4356|2986|98732 A|8765|218|1432567 File 2: B|12|13456|1234567 B|11|13456|123456789 B|33|2986|98732 B|11|2986|14578965 B|8765|218|147584 Common field is third field like 13456, 2986 and 218 in both... (5 Replies)
Discussion started by: Mannu2525
5 Replies

3. Shell Programming and Scripting

sending output to flatfile

Hi, I am writing one unix script to get row count of few tables into one sequential file my script is like this $ORACLE_HOME/bin/sqlplus -s <<EOF >output.txt userid/password@databasename set verify off set heading off set feedback off select count(*) count from tablel where ; select... (4 Replies)
Discussion started by: spmsarada
4 Replies

4. Shell Programming and Scripting

Restricting the merged file size to 1 GB

I am working on a problem in which I need to merge 4 files (say f1,f2,f3 & f4 log files) & then prepare a final file. 1) If the final file created has size more than 1 GB then need to throw error (display error). 2) Need to check after every merge (say f1 + f2, f1 + f2 + f3) that whether... (2 Replies)
Discussion started by: nrm
2 Replies

5. Shell Programming and Scripting

Running a select script through UNIX and sending output to file

Hi, (Oracle, AIX) I have googled this and searched this forum, however I haven't had much luck with an answer and have tried several different things. Basically I have a SQL select statement which generates a whole load of UPDATE statements, I want to run the select statement via... (13 Replies)
Discussion started by: dbchud
13 Replies

6. UNIX for Dummies Questions & Answers

Sending awk output to nothing?

How can I direct awk output to go nowhere? I can write the data to a file easy enough or print it on the screen. But for this particular command I don't actually want the data and I don't want to create a file. I just want the data discarded. Thanks in advance (3 Replies)
Discussion started by: MrEddy
3 Replies

7. UNIX for Dummies Questions & Answers

Sending output of one command to several others?

I know how I can pipe any output to another command thats easy |. What i'm trying to do is send several addresses to the same command over and over again. Essentially what I want to do is do an nslookup on an address and then take the resulting IP(s) and send each of those IP's to another... (2 Replies)
Discussion started by: MrEddy
2 Replies

8. Shell Programming and Scripting

sending field values in columns to output file

Hi, I am trying to send output from a shell scrip to a txt file in a colum format. I have all I can and I dont seem to understand why the results from one one particular file keeps going to the next line. How can I force all to be in one line Please see code and output below The is... (0 Replies)
Discussion started by: asemota
0 Replies

9. Post Here to Contact Site Administrators and Moderators

Duplicate postings when following up on a thread

My post count is probably inflated by something like 20% over the last few days, because the site often posts my reply twice when the load is high. Is there something I can do to avoid this? Is there something I should be doing to notify site administrators about the duplicates? I could click on... (9 Replies)
Discussion started by: era
9 Replies
Login or Register to Ask a Question