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

Add a character

Status
Not open for further replies.

Geek8

Programmer
Apr 23, 2003
31
US
How can I write a script to add a single character to a flat file that has 900,000 records. The character has to be inserted every so many particular bytes. Ex: 2000 bytes. The file then is output to another name so it now has this character at the end of each record.

TIA,


Geek8
 
You open the original file and open a target file. You read from the original and put the character where it needs to be and print the result to the target file. If it needs to be put every 2000 characters you can set $/ to \2000 and do something like ...

print TARGET &quot;${_}char&quot; while <ORIGINAL>;

that is assuming all your records are the same 2000 bytes length. If the length difers then append the character whenever the records ends.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top