The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 11-18-2008
sx3v1l_1n51de sx3v1l_1n51de is offline
Registered User
  
 

Join Date: Jan 2005
Posts: 27
Talking Help with awk script, changing the FS for a single variable

Hi all, im new to awk and would apreciate if you could tell me how to do this, i have a file with several entries like this:

Code:
2008-09-09 21:57:45   44  403 CUSTOM_EVENT                      Upgrade - end1
2008-09-09 21:57:46   45  403 CUSTOM_EVENT                      Component Check - start
2008-09-09 21:57:56   46  403 CUSTOM_EVENT                      Component Check - end
2008-09-09 21:57:56   47  403 CUSTOM_EVENT                      OSChecksum - start
2008-09-09 21:59:15   48  403 CUSTOM_EVENT                      OSChecksum - end
2008-09-09 21:59:15   49  403 CUSTOM_EVENT                      SELLogCheck - start
2008-09-09 22:01:39   50  403 CUSTOM_EVENT                      SELLogCheck - end
2008-09-09 22:01:40   51  403 CUSTOM_EVENT                      USB to Serial Connection Test - start
2008-09-09 22:43:46   52  403 CUSTOM_EVENT                      USB to Serial Connection Test - start
2008-09-09 22:44:15   53  403 CUSTOM_EVENT                      MemoryCheck - start
2008-09-09 22:44:16   54  403 CUSTOM_EVENT                      MemoryCheck - end
im trying to get the values on the last field, which would be the description of the event (eg. USB to Serial Connection Test - start) , but i need to further separate this field with a "-" to know if the test started or ended, the last field is a bit variable so i figured y could use something like this:

cat $1 | awk '{description = $6" "$7" "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15 ; print description }'

first i get all the fields from 6 to 15, and then, i tryed changing the FS to - and print the second field...

cat $1 | awk '{description = $6" "$7" "$8" "$9" "$10" "$11" "$12" "$13" "$14" "$15 ; FS="-" ; print description $2}'

of course, that prints the second field of the entire line, which is the year... hehe... is there a way to tell awk to output the variable's second field delimited by a "-"?

thanks all