Hi!
I have for example a script/file:
+1 echo "toto"
+2 echo "abcdef
+3 echo "dqmsl" $r "dsqlfj"
+4 cat titi | tr \t' ';'
+5 exit
---------------------------------------
I try to find a solution who say:
<ERROR>
The character " has been forgotten a the line 2
The character ' has been forgotten at the line 4
I don't know if you anderstand what I say, but if:
2 or 4 or 6 or 8 or ..... characters " in a line => It is OK
1 or 3 or 5 or 7 or ..... characters " in a line => ERROR! character forgotten
It is the same for ' and `
I think a grep solution exist to recupere the number of character but I don't find it....
Thinks for your help!!!
dangral
December 30, 2004, 10:04am
2
Take a look at your usage of quotes in line 2. You never close the quotes.
Should be:
You have a similar error in line 4
I know this...
I search to do a script which correct my others scripts.
The previous script is a example of script with errors to understand what I want.
dangral
December 30, 2004, 10:54am
4
Why not post your search script or at least the line(s) that is giving you problems. Are we supposed to guess what your code is doing?
If your beef is with quoting, take a look at this , this , and most definitely this .
Cheers
ZB
Ygor
December 30, 2004, 8:01pm
7
You can use the -n option to perform a syntax check for ksh and bash scripts, e.g...
bash -n script1
script1: line 3: unexpected EOF while looking for matching `"'
script1: line 6: syntax error: unexpected end of file
Or you could use awk...
awk '
BEGIN {
FS = "[\042\047]"
}
NF%2 == 0 {
printf "%s: line %d: odd quotes: %s\n", FILENAME, NR, $0
}
' script1
script1: line 2: odd quotes: echo "abcdef
script1: line 4: odd quotes: cat titi | tr \t' ';'
Big thanks Ygor!!!
It is exactly what I would.
I wish you and every body a good new year!