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
Sorting your data with msort iBot UNIX and Linux RSS News 0 05-19-2008 08:20 AM
sorting data using array in ksh ali560045 Shell Programming and Scripting 4 12-04-2007 01:26 AM
Sorting blocks of data alfredo123 Shell Programming and Scripting 8 07-05-2007 07:53 AM
Newbie Awk data sorting i_am_a_robot Shell Programming and Scripting 5 05-04-2007 04:33 AM
Recovering lost folders/files data Yorgy UNIX for Dummies Questions & Answers 0 03-15-2007 02:46 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #22  
Old 05-14-2008
Moderator
 

Join Date: Feb 2007
Posts: 2,328
Try this one:

Code:
awk -v path="/path/too/" -F "|" '{print $0 > path $1}' file
Regards
Reply With Quote
Forum Sponsor
  #23  
Old 05-14-2008
Registered User
 

Join Date: May 2008
Posts: 13
> uname -a
SunOS e2dsavcshrdev01 5.8 Generic_117350-52 sun4u sparc SUNW,Sun-Fire-880

SunOS release 5
How do I find sed and awk versions
Reply With Quote
  #24  
Old 05-14-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
See if using /usr/xpg4/bin/awk works better than /usr/bin/awk or /bin/awk
Reply With Quote
  #25  
Old 05-14-2008
Registered User
 

Join Date: May 2008
Posts: 13
hi Franklin,

awk -v path="/export/home/vinay/" -F "|" '$1 == "AAA" {print $0 > path $1}' number.dat

gives an error:
awk: syntax error near line 1
awk: bailing out near line 1

Please help me if possible


Era I could not get your comment #24.

Regards,
Vinay
Reply With Quote
  #26  
Old 05-14-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,650
You don't have /usr/xpg4/bin/awk on your system, or you didn't understand how to try it? Use the full path name instad of just "awk"; or try "nawk" instead of "awk" (if I understand correctly, that's identical to XPG4 awk, on the Sun box I have access to at least).
Reply With Quote
  #27  
Old 05-14-2008
Moderator
 

Join Date: Feb 2007
Posts: 2,328
Quote:
Originally Posted by Vinaykumar1 View Post
hi Franklin,

awk -v path="/export/home/vinay/" -F "|" '$1 == "AAA" {print $0 > path $1}' number.dat

gives an error:
awk: syntax error near line 1
awk: bailing out near line 1

Please help me if possible


Era I could not get your comment #24.

Regards,
Vinay
Use nawk or /usr/xpg4/bin/awk on Solaris.

Regards
Reply With Quote
  #28  
Old 05-14-2008
Registered User
 

Join Date: May 2008
Posts: 13
Hi Franklin, Era Shiva, Unix gurus,

I finally got the answer. The script you suggested works. It goes like this:
/usr/xpg4/bin/awk -F '|' '$1 == "AAA" { print >"/export/home/vinay/AAA.dat";} $1 == "BBB" { print > "/export/home/vinay/BBB.dat";}' number.dat

Truly good. Thanks a lot for your support . Now I am able to use it in my project.

But one small doubt with respect to comment #13.. I am not able to give my desired path..
sed -e '/^AAA /w/export/home/cmohanku/vinay/AAA1.dat' -e '/^BBB /w/export/home/cmohanku/vinay/BBB1.dat' a.dat
isnt woking. Kindly assist if possible.

Another round of thanks to Franklin, Era, Shiva

Regards,

Vinay
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
regex, regular expressions, solaris

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 08:17 PM.


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

Content Relevant URLs by vBSEO 3.2.0