cat - Tcl echo file contents to transcript -
i'm using simulator uses tcl transcript commands (questa sim) want echo file content "cat" command in unix.
can done in 1 line command @ tcl? possible "cat" 5 first lines of file
to open file , echo contents standard output (just cat
), this:
set f [open $filename] fcopy $f stdout close $f
to first 5 lines (which head -5
), use procedure:
proc head {filename {linecount 5}} { set f [open $filename] {set 0} {$i < $linecount} {incr i} { if {[gets $f line] >= 0} { puts $line } } close $f }
it takes more work because it's more complex detect line endings ship bytes around.
Comments
Post a Comment