regexp in TCL

Programming, for all ages and all languages.
Post Reply
User avatar
Neo
Member
Member
Posts: 842
Joined: Wed Oct 18, 2006 9:01 am

regexp in TCL

Post 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?
Only Human
User avatar
Neo
Member
Member
Posts: 842
Joined: Wed Oct 18, 2006 9:01 am

Re:regexp in TCL

Post 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
Only Human
Post Reply