The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Using grep to extract line number mskarica Shell Programming and Scripting 8 06-25-2008 11:47 PM
extract field of characters after a specific pattern - using UNIX shell script jansat HP-UX 2 05-27-2008 09:08 PM
need to extract field of characters in a line jansat Shell Programming and Scripting 3 05-22-2008 06:44 AM
SED to extract characters Shilpi Shell Programming and Scripting 1 08-03-2007 04:22 AM
SED to extract characters Shilpi Shell Programming and Scripting 2 08-03-2007 04:02 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 07-03-2007
Registered User
 

Join Date: Jan 2005
Posts: 97
Grep and extract the characters after

Hi All,

I have lines like below in a file

A /u/ab/test1.dat
A/u/ab/test2.dat
A /u/bb/test3.dat
A/u/cc/test4.dat

I will need

/u/ab/test1.dat
/u/ab/test2.dat
/u/bb/test3.dat
/u/cc/test4.dat

Pls help

Thanks
Reply With Quote
Forum Sponsor
  #2  
Old 07-03-2007
pressy's Avatar
solaris cultist
 

Join Date: Aug 2003
Location: Vienna / Austria (Europe) [EARTH]
Posts: 718
Code:
root@mp-wst01 # cat testfile
A /u/ab/test1.dat
A/u/ab/test2.dat
A /u/bb/test3.dat
A/u/cc/test4.dat
root@mp-wst01 # cut -f"2" -d"A" < testfile | sed 's/ //' > newfile
root@mp-wst01 # cat newfile
/u/ab/test1.dat
/u/ab/test2.dat
/u/bb/test3.dat
/u/cc/test4.dat
root@mp-wst01 #
regards pressy
Reply With Quote
  #3  
Old 07-03-2007
Registered User
 

Join Date: Sep 2006
Posts: 1,580
Code:
awk '{gsub(/^A\ */,"")}{print}' file
Reply With Quote
  #4  
Old 07-03-2007
Registered User
 

Join Date: May 2007
Posts: 211
I hope that you do not want the first character in your file, so below command would help you

Code:
cut -c2- file > newfile
Reply With Quote
  #5  
Old 07-03-2007
Registered User
 

Join Date: Mar 2006
Location: Bangalore,India
Posts: 1,397
Code:
sed "s/^A *//" filename
Reply With Quote
  #6  
Old 07-04-2007
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,610
Code:
sed 's/^. *//' filename
Reply With Quote
  #7  
Old 07-04-2007
Ygor's Avatar
Moderator
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,248
Code:
sed 's!^[^/]*!!' filename
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 01:28 PM.


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

Content Relevant URLs by vBSEO 3.2.0