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
select a portion of a file into a CSV anju Shell Programming and Scripting 8 02-28-2008 01:50 AM
Select a portion of file based on query vanand420 Shell Programming and Scripting 14 10-31-2006 04:48 AM
How to select line by line in shell preethgideon UNIX for Dummies Questions & Answers 15 10-12-2006 04:35 PM
erasing portion of line with sed (only once) gammaman UNIX for Dummies Questions & Answers 1 07-14-2005 08:40 PM
erasing portion of line with sed gammaman UNIX for Dummies Questions & Answers 5 07-10-2005 10:47 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-11-2008
anju anju is offline
Registered User
  
 

Join Date: Jan 2008
Location: Bangalore
Posts: 17
awk program to select a portion of a line

Hi all,
I am new to awk programs.I have a file like this

vjfavhjlaf<LTEXT>aabcdfffvvbbxbcddjbv</LTEXT>fAFdfdADfd
vjfavhjlaf<LTEXT>aabcdfffvvbbxbcddjbv</LTEXT>fAFdfdADfd
vjfavhjlaf<LTEXT>aabcdfffvvbbxbcddjbv</LTEXT>fAFdfdADfd
vjfavhjlaf<LTEXT>aabcdfffvvbbxbcddjbv</LTEXT>fAFdfdADfd
vjfavhjlaf<LTEXT>aabcdfffvvbbxbcddjbv</LTEXT>fAFdfdADfd

I want to select the text which comes between <LTEXT> and </LTEXT>
This is urgent...Please help..

Thanks in Advance
  #2 (permalink)  
Old 01-11-2008
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,508
sed
Code:
# sed 's/.*<LTEXT>\(.*\)<\/LTEXT>.*/\1/g' file
aabcdfffvvbbxbcddjbv
aabcdfffvvbbxbcddjbv
aabcdfffvvbbxbcddjbv
aabcdfffvvbbxbcddjbv
[n]awk
Code:
# awk '{gsub(/.*<LTEXT>|<\/LTEXT>.*/,"");print}' file
aabcdfffvvbbxbcddjbv
aabcdfffvvbbxbcddjbv
aabcdfffvvbbxbcddjbv
aabcdfffvvbbxbcddjbv
aabcdfffvvbbxbcddjbv
  #3 (permalink)  
Old 01-11-2008
dennis.jacob dennis.jacob is offline Forum Advisor  
dj -------
  
 

Join Date: Feb 2007
Location: Singapore/Bangalore/Cochin
Posts: 560
Please try this

Code:
sed 's!\(.*\)LTEXT>\(.*\)</LTEXT\(.*\)!\2!' filename
  #4 (permalink)  
Old 01-11-2008
anju anju is offline
Registered User
  
 

Join Date: Jan 2008
Location: Bangalore
Posts: 17
awk program to select a portion of a line


Thanks....it worked..!!!!!
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 08:39 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