I am a new to Unix.
${AWK} '\!/^ / && \!/^-/ && \!/^</ && \!/^$/ {printf "%s,,N,N,N,,,,\n", $1}' ~/ozserver.txt
When I run the command like before, there’s errorInfo printed to the Cygwin window as follow:
awk: commandline:1: ^ backslash not last character on line
Actually, my role is translate csh to bash for the learning. I didn’t wrote that code. So, what I know is:
"\!/regex/" : is a model unit."\" is belong to the awk synax for cut down the long sentence
"!"means logical NOT,"/regex/" means one model.btw,"&&" means logical AND.
I just can’t figure out where is wrong. Can anyone give me a sign?
The
csh‘metasyntactic zoo’ means that!is a history operator even inside single quotes, or something like that. In sane^H^H^H^H shells derived from Bourne shell, the!is not such a big problem, and you can simply write:Of course, that can be simplified still further:
That looks for the start of line followed by something other than blank, dash or less than (that isn’t an empty line). That too can be simplified by using a negated character class:
That looks for a line starting with a character other than blank, dash or less than (but it must contain at least one character, so empty lines are automatically excluded). And the last version might even work OK in
cshtoo since it does not use any!at all.