The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Getting remote data through shell script armohans Shell Programming and Scripting 1 04-15-2008 05:07 PM
Help writing shell script in c++ format deadleg Shell Programming and Scripting 2 03-07-2008 07:08 AM
extract data from xml- shell script using awk nishana Shell Programming and Scripting 5 07-16-2007 06:20 AM
format csv file using shell script raosurya UNIX for Advanced & Expert Users 3 06-27-2007 05:57 AM
Pipe data to shell script tomjones07 Shell Programming and Scripting 3 03-14-2007 04:50 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #8  
Old 02-03-2008
rikxik's Avatar
Registered User
 

Join Date: Dec 2007
Posts: 105
From your input/output, you simply don't want to print lines where any of SC1, SC2, SC3, SC4 is empty - thats simple enough that you could have done it yourself:

Code:
#!/usr/bin/ksh

nawk -F"," 'BEGIN{OFS=","}{ if (NR==1) {
                        print "AcquiredMethod, AssetID, AssetLifecycleStatus, C, S/D, 1or2"
                } else {
                        if ($4 != "")
                                print $1,$2,$3,$4,"S",1
                        if ($5 != "")
                                print $1,$2,$3,$5,"S",2
                        if ($6 != "")
                                print $1,$2,$3,$6,"D",1
                        if ($7 != "")
                                print $1,$2,$3,$7,"D",2
                }}' input.csv
The if conditions do it - try a bit harder next time.

HTH
Reply With Quote
Forum Sponsor
  #9  
Old 02-04-2008
Registered User
 

Join Date: Jan 2008
Posts: 5
Thanks!

Thank you for your reply, and sorry to bother you so much!..

Thank you for you advice.

Uday
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 06:27 AM.


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