The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > HP-UX
Google UNIX.COM


HP-UX HP-UX (Hewlett Packard UniX) is Hewlett-Packard's proprietary implementation of the Unix operating system, based on System V.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
need to extract field of characters in a line jansat Shell Programming and Scripting 3 05-22-2008 06:44 AM
Shell Script using Join, empty field help! tibbyuk UNIX for Dummies Questions & Answers 1 02-25-2008 08:33 AM
extract data from xml- shell script using awk nishana Shell Programming and Scripting 5 07-16-2007 06:20 AM
Grep for NULL for a specific field in a unix file sureshg_sampat UNIX for Dummies Questions & Answers 5 11-24-2006 05:21 AM
How to extract data using UNIX shell script? desiondarun Shell Programming and Scripting 3 08-09-2006 05:14 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-22-2008
Registered User
 

Join Date: May 2008
Posts: 4
Stumble this Post!
extract field of characters after a specific pattern - using UNIX shell script

Hello,

Below is my input file's content ( in HP-UX platform ):

ABCD120672-B21 1
ABCD142257-002 1
ABCD142257-003 1
ABCD142257-006 1

From the above, I just want to get the field of 13 characters that comes after 'ABCD' i.e '120672-B21'... . Could you please let me know the shell script that I have to use?

Thanks
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-22-2008
Moderator
 

Join Date: Feb 2007
Posts: 1,953
Stumble this Post!
Try this:

Code:
sed 's/ABCD\(.*\) .*/\1/'  file > newfile
Regards
Reply With Quote
  #3 (permalink)  
Old 05-27-2008
Registered User
 

Join Date: May 2008
Posts: 7
Stumble this Post!
Try this,


echo "ABCD120672-B21 1"|cut -c 5-16
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:31 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0