1753918 Members
7766 Online
108810 Solutions
New Discussion

awk and shell problem

 
SOLVED
Go to solution
pareshan
Regular Advisor

awk and shell problem

Could anyone help me with this plz......I haven't done much of awk and came across this which i couldnt solve

What does this do?

o awk -F':' '/^[Tt]he c.?[tw] jumps over the moon/{ print $1 }' ~/tmp/foo

In PERL what does this mean?

o $a->{‘foo’}

In ksh what does this do?

o myhost$ >/tmp/foo

Thanks in advance
i will really appreciate the help
4 REPLIES 4
VK2COT
Honored Contributor

Re: awk and shell problem

Hello,

Firstly, your current ITRC status is
not flattering:

"I have assigned points to 63 of 132
responses to my questions."

If you want to show appreciation when others
take time to reply to your questions, at a
minimum you should assign points.

Secondly, these are classical school
assignment questions. If you ever
had a chance to log into any Unix and/or
Linux servers, why did not you try to run
these commands and see what they do.
Believe me, the answers are very
simple and even logical. Plus,
on-line manuals for awk, Shell and perl
would help immediately too.

ITRC forums should not be abused as each
of us have other serious jobs to do.

Cheers,

VK2COT
VK2COT - Dusan Baljevic
Laurent Menase
Honored Contributor
Solution

Re: awk and shell problem

1 $ awk -F':' '/^[Tt]he c.?[tw] jumps over the moon/{ print $1 }' ~/tmp/foo

for every line in $HOME/tmp/foo like
The c..t jumps over the moon :1234
it prints what is before ":"
-F : is for field separator definition
/^pattern/{action}
execute action for each line starting with the pattern
print $1 since we have -F : will display what is before :



In ksh what does this do?

o myhost$ >/tmp/foo

myhost$ is your prompt apparantly
so it trucate /tmp/foo

open /tmp/foo with create, truncate flag, and since there is nothing to execute on the line close it
so just a truncate

pareshan
Regular Advisor

Re: awk and shell problem

Thanks alot
pareshan
Regular Advisor

Re: awk and shell problem

thanks