Tcl

Created Tuesday 01 July 2014

http://www.tcl.tk/man/tcl8.5/tutorial/Tcl0.html

File access
http://www.tcl.tk/man/tcl8.5/tutorial/Tcl24.html

File commands
http://wiki.tcl.tk/1041

Make dir
http://wiki.tcl.tk/10076

Delete file/dir
http://wiki.tcl.tk/10058

Check if file exists
http://wiki.tcl.tk/10071

Check if dir exists
http://wiki.tcl.tk/10073

Copy file
http://wiki.tcl.tk/10068

Replace regexp
http://www.tcl.tk/man/tcl/TclCmd/regsub.htm

Replace in string
http://wiki.tcl.tk/2819

Replace a line in a file (+ set a timestamp)
http://stackoverflow.com/questions/2818130/in-tcl-how-do-i-replace-a-line-in-a-file
set timestamp [clock format [clock seconds] -format {%Y%m%d%H%M%S}]
set filename "filename.txt"
set temp $filename.new.$timestamp
set backup $filename.bak.$timestamp

set in [open $filename r]
set out [open $temp w]

# line-by-line, read the original file
while {[gets $in line] != -1} {
#transform $line somehow
set line [string tolower $line]

# then write the transformed line
puts $out $line
}

close $in
close $out

# move the new data to the proper filename
file link -hard $filename $backup
file rename -force $temp $filename



Backlinks: