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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to read first 2000 bytes of a file and search/replace

Status
Not open for further replies.

eholdo

Technical User
May 30, 2002
31
US
Hello,
using csh I need to read in the first 2000 bytes of a file, look for the expression (not including quotes)
"%PDF" and split the file before into one file, and the string plus what follows into a separate file, then replace the first 2000 bytes of the original file with the second file (the one that starts with "%PDF".

Help.... running Solaris 8 and csh shell

Thanks!
 
And what have you so far ?
And why insisting on csh ?
 
The rest of the rather intricate script is in csh. As for so far, this is a new requirement, so I have an input filename and an output filename.... just need the rough direction as to which way to go, ie- sed, etc
Thanks!
 
man dd
man grep
By the way, if the pdf file is binary you're in trouble ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Ok....why am I in trouble if it's a Binary pdf?
Thanks
 
Because most of the *nix file utilities are designed for text files.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I think I got by this by dd on the first 8 blocks and count =1 files=1 which gives me the first 8 blocks, which are straight text. Soooo, now I just need to figure out how to find the byte position of a character "%" in a file.

Any help is greatly appreciated!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top