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

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -

php - Accessing static methods using newly created $obj or using class Name -