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

file access

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
once creating a file stream, can one access specific lines of the file? I for instance want to open the file, find a line that starts with a certain word and then change that line.....

thanks
 
How about:
set fid [open <filename> r+]
set filelist [split [read $fid] \n]
seek $fid 0 start
foreach line $filelist {
if {[string range $line <range of your word>] != <your word>} {
puts $fid $line
} else {
set line2 <do whatever to that line>
puts $fid $line2
}
close $fid Bob Rashkin
rrashkin@csc.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top