LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   awk strange behaviour in tcsh (https://www.linuxquestions.org/questions/linux-software-2/awk-strange-behaviour-in-tcsh-105059/)

flyingalex 10-17-2003 05:53 AM

awk strange behaviour in tcsh
 
Hi folks

This command under tcsh does not work

awk "BEGIN {print \" Don't Panic \" } "

resulting in

Unmatched ".

while it works fine under bash!

Does anyone have any idea about the reason of it?

cheers

Alex

jkobrien 10-17-2003 07:39 AM

Hi,

Don't know the reasons why, but using hex codes does work under tcsh
awk 'BEGIN {print "\x22 Don\x27t Panic \x22" }'

John

flyingalex 10-17-2003 09:29 AM

Hi

it does work, but writes the double quotes too, as
they also were part of the string.
That's different from the original idea.
Also you used single quotes before BEGIN and at the end of the line.
Let me know if you find some other solution.

jkobrien 10-17-2003 10:03 AM

Sorry, I thought you wanted the quotes. In that case...

awk 'BEGIN {print "Don\x27t Panic" }'

... is what you want.

Why do you care about using single quotes around the awk command? Are you just trying to understand how the t shell works with quote marks? I've always had a hard time keeping that straight, and generally just mess around until I find what works.

John

flyingalex 10-17-2003 10:15 AM

Hi

Thanks John!Indeed it works!
I still wonder why the two shells behave so
differently though, what the reason of it really is!

Let me know if you come with some idea about it.

Alex

jkobrien 10-17-2003 10:27 AM

Hi Alex,

Well the short answer is that the bash shell and the tcsh shell just handle quote marks differently depending on what the authors thought would work best.

If you read up on bash, on tcsh and on awk, I'm sure you'll get it all sorted out as to how each behaves and they're not totally inconsistent with each other. But, speaking for myself, it's hard to keep that clear in my memory so usually in a situation like that I just mess around with various combinations until I hit on the one that works. With experience it doesn't take long.

John


All times are GMT -5. The time now is 12:02 AM.