The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 02-10-2009
deepaktanna deepaktanna is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 4
Question insert a header in a huge data file without using an intermediate file

I have a file with data extracted, and need to insert a header with a constant string, say: H|PayerDataExtract

if i use sed, i have to redirect the output to a seperate file like

sed ' sed commands' ExtractDataFile.dat > ExtractDataFileWithHeader.dat

the same is true for awk

and in its simplist form i could say
echo 'H|PayerDataExtract' > ExtractDataFileWithHeader.dat
cat ExtractDataFile.dat >> ExtractDataFileWithHeader.dat
mv ExtractDataFileWithHeader.dat ExtractDataFile.dat

but in all of the above an extra file is created. If i were to do this in vi manually the extra file could be avoided.

Is there a way to avoid the extra file while still not having to manually use vi in a interactive manner? This is even more neccessary if the file uses over 50% filespace and an extra file will just double my usage , though temporarily