bharath kumar
bharath kumar

Reputation: 165

Execute sed command inside TCL script

I am trying to execute sed command inside TCL script . Basically i wanted to remove all empty lines from the input file before reading the file using TCL. so i tried following in my script

 exec sed -i '/^\s*$/d' .tmp.PG_Ring
 set fid [open ".tmp.PG_Ring" r]

But the script is dumping following Error .

sed: -e expression #1, char 1: unknown command: `''
while executing
"exec sed -i '/^\s*$/d' .tmp.PG_Ring"
(file "pg_ring.tcl" line 1)

could you please provide me work around for this & help me with best way to do this?

Upvotes: 0

Views: 4688

Answers (1)

Donal Fellows
Donal Fellows

Reputation: 137667

That won't work, as single quotes have no special meaning to Tcl at all. Tcl uses braces to mean the same sort of thing (except they nest nicely), so instead you can use this:.

exec sed -i {/^\s*$/d} .tmp.PG_Ring

Upvotes: 4

Related Questions