awk warning on escape sequence
I am firing an `awk` command with the character class ere.
Code:
cere='^[[:space:]]*([#;!]+|@c|\/\/)[[:space:]]*' Code:
awk: warning: escape sequence `\/' treated as plain `/' |
Well with zero clue on how it is being used, it is only a warning, so i guess try it and see?
|
I want to match C and C++ comments (//)
|
and your post does not explain how is it used. Anyway, this is a warning, and that warning means [usually] there is a superfluous [or missing] backslash somewhere. Now it was just ignored.
|
Try to double each backslash
Code:
cere='^[[:space:]]*([#;!]+|@c|\\/\\/)[[:space:]]*' Code:
cere='^[[:space:]]*([#;!]+|@c|//)[[:space:]]*' |
I want to match regions of lines between a begin line and an end line.
For the following comments in bash, cere will match the comment symbol followed by any spaces. Code:
# Mode: rec Code:
// Mode: rec |
You still don't understand. Do not only explain what do you want to achieve, but show how did you implement it.
Every command will be first evaluated by the shell before executing it and passing the arguments to it. So the real command line may differ from the one you actually specified. It all depends on the quotation, escape sequences and other tricky things. Without details we will unable to se what's going on. But regarding the original situation: awk reported it found a backslash, but \/ is not a valid escape sequence. TBH it is syntactically incorrect. awk ignored that \ for you - assuming that is just superfluous - and dropped a warning message about that. Finally why don't you try it, if that works? |
Here is the awk call
Code:
charcl_ere='^[[:space:]]*([#;!]+|@c|\/\/)[[:space:]]*' |
Then you want // and it should be
Code:
cere='^[[:space:]]*([#;!]+|@c|//)[[:space:]]*' |
You do realise you can just change the shebang and use all awk?
|
All times are GMT -5. The time now is 10:51 AM. |