What happened with AWK?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting What happened with AWK?
# 1  
Old 02-21-2005
What happened with AWK?

The second script seems not to work.
Quote:
266 lab2-19:~> cat directory
abs utah 12343
cde utah 230548
asf tar 2597
lasfj utah 2057


268 lab2-19:~> awk '$2~/utah/{print $2 ", " $1}' directory
utah, abs
utah, cde
utah, lasfj


270 lab2-19:~> cat new.awk
BEGIN {FS=" "}
{
$2~/utah/
{
print $2 ", " $1
}
}

271 lab2-19:~> awk -f new.awk directory
utah, abs
utah, cde
tar, asf
utah, lasfj

Last edited by endeavour1985; 02-21-2005 at 06:54 PM..
# 2  
Old 02-21-2005
Why my second script doesn't work?
# 3  
Old 02-21-2005
When I changed the second script into the following:
Code:
BEGIN {FS=" "}
$2~/utah/
{
      print $2 ", " $1
}

The output became:
Quote:
272 lab2-19:~> awk -f new.awk directory
abs utah 12343
utah, abs
cde utah 230548
utah, cde
tar, asf
lasfj utah 2057
utah, lasfj
# 4  
Old 02-21-2005
OK, I know now, it must be written this way:
Code:
BEGIN {FS=" "}
$2~/utah/{
      print $2 ", " $1
}

Login or Register to Ask a Question

Previous Thread | Next Thread

7 More Discussions You Might Find Interesting

1. What is on Your Mind?

What happened to coolerbooks?

I just found the website coolerbooks.com a couple weeks ago. It was a site that had loads of free ebooks for download. But now it seems to have been hijacked by some Microsoft search thing. There was an article last year claiming it teamed with Google (the anti-Microsoft!) to offer the... (2 Replies)
Discussion started by: KenJackson
2 Replies

2. Solaris

what happened to admintool?

what happened to admintool in Solaris10? (2 Replies)
Discussion started by: mndavies
2 Replies

3. UNIX for Dummies Questions & Answers

What Happened :(

Hello, I have created a dosrename script and it was working fine unitl today. I can't think what i have changed (don't think i have to be honest). The error is when i run the script it says the file i am trying to rename does not exist when it blatently does. Or is it a typo when i run the... (4 Replies)
Discussion started by: jazz8146
4 Replies

4. UNIX for Dummies Questions & Answers

What happened to mkisofs ?

I've been using a mkisofs line like this for years without problem # mkisofs -J -R -V 'Vol Label' -o /output/path/FILE.ISO /input/path/ Now, however, it gives a UTR-8 character message at the start INFO: UTF-8 character encoding detected by locale settings. Assuming UTF-8... (0 Replies)
Discussion started by: Bobby
0 Replies

5. What is on Your Mind?

what happened to ygor..??

:D anyone hear from ygor..? haven't seen him post in a while... wonder what he is up to..! the last i heard he was the D25khan.. that was him right guys ??? being a newbie myself that is one dude that i admire. him Norsk, Perdebro, RTM , Google and Zazzybob all real genius.. and the most... (2 Replies)
Discussion started by: moxxx68
2 Replies

6. SuSE

What happened to my three threads?

I posted three specific queries relating to Suse earlier today but they've disappeared. I originally incorrectly posted them in the Unix begiiners forum, edited them out from there and re-posted under Linux. I'm guessing they've been mistaken for some kind of flood post as they have the same... (3 Replies)
Discussion started by: Mark Ward
3 Replies

7. Post Here to Contact Site Administrators and Moderators

what happened?

A few hours ago I made several reasonable posts to this forum and now they have dissapeared. I read and followed the rules, and I sure didn't break any, but gone they are :( I know I only joined the forum today, but do the posts have to be authorised or something? ... (14 Replies)
Discussion started by: cw1972
14 Replies
Login or Register to Ask a Question