Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add/append a line on the top of a txt file. 1

Status
Not open for further replies.

sharma29

Technical User
Sep 11, 2003
10
0
0
GB
What to add header line as the first line to a file created from a sql(oracle) file.
The sql file output(output.txt) is as follows;
REV|23453253||TEST TEST|DUMP NE23 5SD
REV|23454345|2|TEST TEST|TEST NE49

The header line I was trying to add is
"3P_CREDITORS" "5" "" "31-OCT-2008"
which is in another file(input file). I was trying like

head -1 inputfile.dat >> output.txt
understanably addes to the end.

REV|23453253||TEST TEST|DUMP NE23 5SD
REV|23454345|2|TEST TEST|TEST NE49
"3P_CREDITORS" "5" "" "31-OCT-2008"

I want it as
"3P_CREDITORS" "5" "" "31-OCT-2008"
REV|23453253||TEST TEST|DUMP NE23 5SD
REV|23454345|2|TEST TEST|TEST NE49

I want the head command to work on top.

For those who want to know how I create the output file(output.txt) I am using the sql script and I spool from the sqlplus to get the output file.
 
Hi

Code:
(
  head -1 inputfile.dat
  cat output.txt
) > output_new.txt

[gray]# or[/gray]

sed '1i"3P_CREDITORS" "5" "" "31-OCT-2008"' output.txt > output_new.txt


Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top