redirecting output retaining the input


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers redirecting output retaining the input
# 1  
Old 06-14-2010
redirecting output retaining the input

Hi Guys,

I am trying to redirect output from a file to another file while retaining the contents of the input file.
For ex:
cat /tmp/Out1.cfg > test.txt
Now, test.txt would contain the value of Out1.cfg.,ie say for ex "12"
What i require is to have the value as "/tmp/Out1.cfg 12" in the output file.
Smilie
Is there any way to achieve this? Please let me know..
Thanks in advance..

Regards,
Kiran
# 2  
Old 06-14-2010
One way:
Code:
echo /tmp/Out1.cfg | cat - /tmp/Out1.cfg > test.out

or simply
Code:
echo /tmp/Out1.cfg > test.out
cat /tmp/Out1.cfg >> test.out


Last edited by Scrutinizer; 06-14-2010 at 03:37 AM..
# 3  
Old 06-14-2010
Code:
# cat file
12

Code:
# ./add file
FileName: file
----------------------------------------
12


Code:
#!/bin/bash
echo "FileName: $1" >> output
echo "----------------------------------------" >> output
cat $1 >> output
cat output

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Redirecting output to file

Hi, I have created script which redirect the output to file.I am able to get the output in file but not in the format. Output :Content of the log which have 10 -15 lines. Actal :Line1 ..Line 2Line3 Line4 Line 5 Expected:Line1 Line 2 Line3 Please... (7 Replies)
Discussion started by: karthik771
7 Replies

2. Shell Programming and Scripting

Pls HELP: Redirecting input to SFTP connection

Hi, Can somebody please let me know if we can redirect variable value to the sftp connection. I am trying to run the attached snippet but facing an error. dev@UAT.com> export USER1=ftp dev@UAT> export HOST1=XX.XX.XX.XX dev@UAT> export INPUTDATA2='lcd /Z02/apps/output/UAT/CMUP/incoming cd... (9 Replies)
Discussion started by: Khan28
9 Replies

3. Shell Programming and Scripting

Redirecting the output

For example, if we run the below command, symcfg list -thin -pool , results in an output most of the times and if the out is generated i'm able to redirect the output to a file. but sometimes it doesnt result any output and even though the output is being redirected, i can see "No Thin Pools "... (2 Replies)
Discussion started by: web2moha
2 Replies

4. Shell Programming and Scripting

Retaining file versions based on input parameter

Hello Forum. I have the following files in one directory: abc_july01_2013.txt abc_july02_2013.txt abc_july03_2013.txt abc_july04_2013.txt abc_july05_2013.txt abc_july06_2013.txt abc_july07_2013.txt abc_july08_2013.txt If I want to be able to keep the last 5 versions of the file and... (4 Replies)
Discussion started by: pchang
4 Replies

5. Shell Programming and Scripting

redirecting output using if-then-else in awk

I am trying to filter records based on number of "|", delimiter in my application. If number of "|" is greater than 14 its a bad record, else its a good record. I have to redirect output to two different files based on the if-then-else evaluation in AWK. if number of “|” in file_0 > 14 ... (2 Replies)
Discussion started by: siteregsam
2 Replies

6. UNIX for Dummies Questions & Answers

redirecting script output

Hello, I am interested in taking the output from a script i wrote and using it as input to a different script i wrote. So for example i want to take the output from program2 and use it as a parameter for program1. I didnt think i could use the >> symbols because i think that is just for .txt... (4 Replies)
Discussion started by: GmGeubt
4 Replies

7. Shell Programming and Scripting

Redirecting output to file

Hi, Below is the whole string which is to be redirected to the new file. su - oracle -c "exp $user/$pass file=/oracle/oradata/backup/exp_trn_tables_`date +%d_%b_20%y_%H_%M_%S`.dmp log=/oracle/oradata/backup/exp_trn_tables_`date +%d_%b_20%y_%H_%M_%S`.log tables=table1,table2 statistics=none" ... (3 Replies)
Discussion started by: milink
3 Replies

8. UNIX for Dummies Questions & Answers

Redirecting 'find' output...

Hi all, why does one version of this command work but not the other? - This file already exists with 644 mod permissions - I am logged in as d269836, no su rights. - Box is 'SunOS' running bash I think; but runs ksh scripts OK. This one works: find /users/d269836 -type f -name "*.txt"... (6 Replies)
Discussion started by: dan-e
6 Replies

9. Shell Programming and Scripting

Redirecting OUTPUT

Hi, I want to move the output of a command/script to a file as well as to to be displayed on stdout. Can anybody help me in this. Thanks in advace .. -Chanakya M (1 Reply)
Discussion started by: Chanakya.m
1 Replies

10. Shell Programming and Scripting

Retaining Spaces while redirecting output

I need to merge data from more than one file and I am using while read line_record do field1=`echo $line_record | awk -F "," '{ print $1 }'` echo $line_record >> $outFile if then while read new_linerec do echo $new_linerec... (3 Replies)
Discussion started by: skrakesh
3 Replies
Login or Register to Ask a Question