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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
display changing variable in one place on screen in ksh raidzero Shell Programming and Scripting 7 09-25-2008 10:24 AM
rerun .profile after changing variable sboxtops AIX 2 09-02-2008 03:19 PM
bash script execution with a variable in a single line shoeb Shell Programming and Scripting 1 07-06-2008 05:14 AM
IFS changing the variable value pvar Shell Programming and Scripting 1 02-25-2005 06:21 PM
Very simple question about changing PS1 variable at startup! abidmalik UNIX for Dummies Questions & Answers 2 08-26-2002 02:05 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:48 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0