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



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
concatenate and display 2 lines as 1 with a condition for 2 line ? vithala Shell Programming and Scripting 7 07-11-2008 01:01 AM
Need solution concatenate and display 2 lines as 1 with a condition for 2 line ? vithala UNIX for Advanced & Expert Users 1 07-10-2008 01:27 PM
How to enter if-then condition on command prompt/line ? mpc8250 Shell Programming and Scripting 3 02-10-2008 12:27 PM
ROX-Filer 2.7.1 (Stable branch) iBot Software Releases - RSS News 0 01-09-2008 06:30 AM
[OpenServer 5]Line Printing and special character (é @) tankd UNIX for Dummies Questions & Answers 5 08-02-2007 03:44 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-10-2009
bhaskar_m bhaskar_m is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 47
How to filer a line in special condition?

Hi,
I hava log file which has the following output :
Created RELEASE in dist/filename_release_1_0_20090210.zip
Created RELEASE in dist/filename_release_1_1_20090210.zip
Created RELEASE in dist/filename_release_1_3_20090210.zip
Created RELEASE in dist/filename_release_1_0_20090210.zip
Created RELEASE in dist/filename_release_1_0_20090210.zip
Created RELEASE in dist/filename_release_1_4_20090210.zip
Created RELEASE in dist/filename_release_1_0_20090210.zip
Created RELEASE in dist/filename_release_1_0_20090210.zip
Created RELEASE in dist/filename_release_1_0_20090210.zip
Created RELEASE in dist/filename_release_1_0_20090210.zip

for special sorting purpuse I want each of the line to be filtered like

/filename_1_0
/filename_1_1
/filename_1_3
/filename_1_0
/filename_1_0
/filename_1_4
/filename_1_0
/filename_1_0
/filename_1_0
/filename_1_0

i.e the "release" word to be filtered out and version is to be attached woth the file name. As I am new to the filtering part of UNIX could not make out what to use any sed/awk/perl ..Please help. Waiting for an aspiring response. Thank you.
  #2 (permalink)  
Old 02-10-2009
scorpio scorpio is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 41
try sed commnad like this
sed -e 's/.*dist//' < filename
  #3 (permalink)  
Old 02-10-2009
bhaskar_m bhaskar_m is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 47
Quote:
Originally Posted by scorpio View Post
try sed commnad like this
sed -e 's/.*dist//' < filename

Its ok...but how to remove on of the "release" word and add the version and remove the time stamp to flitered output could u plz gelp on this more?
  #4 (permalink)  
Old 02-10-2009
scorpio scorpio is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 41
sorry ..

This is the complete command

sed -e 's/.*dist//' < testfile.txt | cut -d "_" -f1-4
  #5 (permalink)  
Old 02-10-2009
bhaskar_m bhaskar_m is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 47
Quote:
Originally Posted by scorpio View Post
sorry ..

This is the complete command

sed -e 's/.*dist//' < testfile.txt | cut -d "_" -f1-4
Excellent sir ...but still it is not removing the "release" word else is ok. Waiting for an aspiring response from your side.
  #6 (permalink)  
Old 02-10-2009
sunpraveen's Avatar
sunpraveen sunpraveen is offline
Registered User
  
 

Join Date: Jan 2009
Location: Pruthvi
Posts: 85
Bhaskar,

Try the below command.

Code:
cut -d '/' -f2 < filename | sed -e 's/release_//g' -e 's/.zip//g' | cut -d '_' -f1-3
HTH,

Regards,

Praveen
  #7 (permalink)  
Old 02-10-2009
bhaskar_m bhaskar_m is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 47
HI Praveen,
Superb!! Its working fine. Thanks for this nice help.
Regards,
Bhaskar
Sponsored Links
Closed Thread

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 12:19 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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