Documentation can be found at http://tcllib.sourceforge.net/doc/fileutil.html
Currently the fileutil package contains
2003-11-28 VI Nice of you to ask. There's a list above, other than that: tail -f, split, join. I use tkcon as my main shell on a wimpy laptop. Fewer dlls loaded is good..
Other procs that would be useful to add would include wc, tee, head, tail, and perhaps some awk'ish type functions ala Tclx.
For more on grep, see "NR-grep: A Fast and Flexible Pattern Matching Tool" [L1 ].
Perhaps even some code like Glenn Jackman's:
proc touch {filename {time ""}} { if {[string length $time] == 0} {set time [clock seconds]} file mtime $filename $time file atime $filename $time }
glennj: This proc has been accepted into tcllib 1.2: http://tcllib.sourceforge.net/doc/fileutil.html
US Unix-like touch:
proc touch {filename {time ""}} { if {![file exists $filename]} { close [open $filename a] } if {[string length $time] == 0} {set time [clock seconds]} file mtime $filename $time file atime $filename $time }
2003-12-16 SS Trying to improve over the Tcl implementation of wc in the Great Language Shootout I wrote this, that seems half in execution time against big files:
set text [read stdin] set c [string length $text] set l [expr {[llength [split $text "\n\r"]]-1}] set T [split $text "\n\r\t "] set w [expr {[llength $T]-[llength [lsearch -all -exact $T {}]]-1}] puts "\t$l\t$w\t$c"
Output seems to be identical to GNU's wc command.
SEH 20060723 -- The proc fileutil::find is useful, but it has several deficiencies:
The following code eliminates all the above deficiencies. It checks for nested symbolic links in a platform-independent way, and scans directory hierarchies without recursion.
For speed and simplicity, it takes advantage of glob's ability to use multiple patterns to scan deeply into a directory structure in a single command, hence the name. Its calling syntax is the same as fileutil::find, so with a name change it could be used as a drop-in replacement:
SEH 20080120 -- globfind has been rewritten to achieve greater speed, simplicity and function, and moved to its own page.
LV People who write utilities that seem like they would be useful should submit them to the tcllib sf.net feature request facility, so the maintainers can take a look at them.
gavino posted a question on comp.lang.tcl:
"I can not figure out the [globfind] syntax to limit it to finding say .pdf files. ... please someone post and [sic] example."
and Gerald Lester replied:
proc PdfOnly {fileName} { return [string equal [string tolower [file extension $fileName] .pdf] } set fileList [globfind $dir PdfOnly]
SEH 20070317 -- A simpler alternative:
set fileList [globfind $dir {string match -nocase *.pdf}]
It should be noted by those who are not familiar with unix - that even in windows xp, if fileutil::find encounters a folder or file named with a single tilde (~), it will append the contents of the person's home directory to the search results. Furthermore, there is a risk of infinite recursion, if somewhere within your home folder, there is also a folder named with a single tilde.
-Laif
See also Unixy minitools
Category Package, subset Tcllib | Category File |
---|