Page 1 of 1

regexp in TCL

Posted: Wed May 04, 2005 6:04 am
by Neo
I have a file with the following contents
...some many lines
...
....
file1();
file2();
I need to check if the given pattern (by the user) matches an uncommented line in the file.
I use this

Code: Select all

egrep ^file1\(\) filename
Does anyone know how can I do this in a TCL script?

Re:regexp in TCL

Posted: Wed May 04, 2005 9:27 pm
by Neo
I need to rearrange the arguments provided to my script in a particular order.
For e.g. the arguments ending with .java must come first, the ones with .c next etc..
There may be a variable no. of args on the cmd line.
I tried doing this with a for loop in bash. The problem is I use grep for matching and how can I match more that I pattern in the loop?
Can I do a test with the grep command as a argument in it. I tried this but am getting an error

Code: Select all

for var in "$@"; do
        if [ 'echo $var | egrep "\.java$">/dev/null' -eq 0 ]; then
                export javafile=$var
        fi
done