The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
read a variable character by character, substitute characters with something else vipervenom25 UNIX for Dummies Questions & Answers 2 06-06-2008 12:18 PM
Korn: How to loop through a string character by character shew01 Shell Programming and Scripting 9 05-29-2008 06:47 AM
replace a character with another character satish@123 Shell Programming and Scripting 4 05-19-2008 02:57 AM
Can i read a file character by character karnan Shell Programming and Scripting 6 05-18-2008 11:22 PM
Can I read a file character by character? murtaza Shell Programming and Scripting 3 03-29-2007 08:19 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-25-2006
Registered User
 

Join Date: Oct 2006
Location: Bangalore, India
Posts: 41
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Setting FS to more than one character

Hi!

In an awk tutorial i was reading (from www.grymoire.com), it was mentioned that i can set the input field separator to more than one character using FS. However when i tried it out, it wasnt working.

File a :

abc/:/:as
as/:f/:f
AE/:/:as/:/:s


script a.sh

#!/bin/awk -f
BEGIN {
FS="/:";
}

{
print $1, $2;
}



command:

home/# as.sh<a
abc :
as :f
AE :


however, the output i shud get is
abc
as f
AE

can someone tell me what am i doing wrong here?
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 10-26-2006
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,628
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Theat awk command worked fine for me. Try replacing awk with nawk.
Reply With Quote
  #3 (permalink)  
Old 10-26-2006
Registered User
 

Join Date: Oct 2006
Location: Bangalore, India
Posts: 41
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Quote:
Originally Posted by vino
Theat awk command worked fine for me. Try replacing awk with nawk.
Thanks! it worked. But why didnt awk work? coz the tutorial was written for Awk, not nawk. The tutorial was for Solaris n my flavor is also Solaris. It was written in 1989 tho - did that make any difference?
Reply With Quote
  #4 (permalink)  
Old 10-26-2006
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,279
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
Solaris has a crippled version of awk - which is the default. It also has nawk which is more like new awk and supports features.

There are POSIX standards for awk which came out long after the awk version Solaris has...

see:
http://www.opengroup.org/onlinepubs/...ities/awk.html

POSIX is a set of standards developers of most flavors of UNIX try to follow.
This allows, for example, somebody here running Linux to get an example from someone else on this forum - that other person runs Solaris - and there will be a good chance it works on both boxes. Solaris doesn't play POSIX with awk, but it's there to support old code. Just use nawk and forget awk. IMO.
Reply With Quote
  #5 (permalink)  
Old 10-26-2006
Registered User
 

Join Date: Oct 2006
Location: Bangalore, India
Posts: 41
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Spurl this Post!
thanks! after a cloudy day, its a sunny one again!
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:58 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101