Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tcl equivalent to a Perl one-liner

Tags:

regex

tcl

I found myself using a lot of Perl one-liner regexes in my code when I need some small processing on ASCII files which I don't want to open for editing.

Is there a Tcl equivalent to this Perl one-liner command?

perl -i.bak -pe 's/old/new/gi' filename
like image 690
Roman Kaganovich Avatar asked Nov 03 '22 11:11

Roman Kaganovich


2 Answers

look at the owh script of Richard Suchenwirth http://wiki.tcl.tk/906 which gives this sort of functionality. Joachim

like image 65
joheid Avatar answered Nov 15 '22 13:11

joheid


I once wrote a Tcl script to provide Perl-like command line options. I never used it much myself -- it ended being an exercise in working with sending code to an Tcl interp. If you're interested, the code is at https://bitbucket.org/glenn_j/tcl-command-line-one-liners/src

like image 45
glenn jackman Avatar answered Nov 15 '22 13:11

glenn jackman