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
using awk to extract text between two constant strings mjoshi Shell Programming and Scripting 11 03-31-2009 09:37 AM
using AWK how to extract text between two same strings santosh1234 Shell Programming and Scripting 2 12-23-2008 05:37 AM
is it hard to extract particular lines & strings from the files?? thepurple Shell Programming and Scripting 8 11-16-2008 10:01 AM
How to search multiple strings in a file deepakpv Shell Programming and Scripting 2 09-19-2008 03:02 AM
Problem to search multiple strings sudhish Shell Programming and Scripting 2 10-25-2007 02:00 PM

Closed Thread
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
  #1 (permalink)  
Old 01-22-2009
vin_eme vin_eme is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 2
how to extract multiple strings from a line

Hi

I have the following requirement. i have the following line from a log file

one : two : Three : four : five : six : seven : eight :nine :ten

Now can you pls help what i should do to get only the following output from the above line

two : five : six : seven : Eight

appreciate your help on this

thanks,
Vince
  #2 (permalink)  
Old 01-22-2009
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,277
Code:
awk -F: '{print $2,$5,$6,$7,$8}' OFS=":" infile
 two : five : six : seven : eight
  #3 (permalink)  
Old 01-22-2009
udhay udhay is offline
Registered User
  
 

Join Date: Jul 2008
Posts: 3
Try with awk....( remove ":" if it's not required ).

awk '{print $2,":"$5,":"$6,":"$7,":"$8}' logfile

Udhay
  #4 (permalink)  
Old 01-22-2009
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,361
Quote:
Originally Posted by vin_eme View Post
Hi

I have the following requirement. i have the following line from a log file

one : two : Three : four : five : six : seven : eight :nine :ten

Now can you pls help what i should do to get only the following output from the above line

two : five : six : seven : Eight

Code:
line="one : two : Three : four : five : six : seven : eight :nine :ten"
IFS=' :'
set -f
set -- $line
printf "%s : " $2 $5 $6 $7; echo $8
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 05:40 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