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!

File Manipulation

Status
Not open for further replies.

dcomit

Technical User
Jun 20, 2001
115
GB
I've written a tcl program to read a file, do some massaging and output to another file. What I need to do initially is to strip off the first and last records. Is there a simple way to achieve this?

Thanks,
Dave
 
It depends on the size of the file. Assuming it's not too big (you decide what too big means), and that the records are linefeed-delimited, I like to do this:
Code:
set fid [open <filename> r]
set lstLines [split [read $fid] \n]
close $fid
set lstLines [lrange $lstLines 1 end-1] #first and last removed

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top