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
Removing duplicates in a sorted file by field. kinksville Shell Programming and Scripting 1 04-29-2008 11:03 AM
Removing parts of a specific field kieranh Shell Programming and Scripting 9 09-28-2007 09:52 AM
removing line and duplicate line ocelot UNIX for Dummies Questions & Answers 11 01-30-2007 09:44 AM
Replacing the last field of a line. Darek Shell Programming and Scripting 3 08-19-2005 08:45 AM
AWK line by line instead of field by field? yongho Shell Programming and Scripting 2 07-06-2005 02:49 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 12-11-2006
Registered User
 

Join Date: Dec 2006
Posts: 3
Unhappy removing last field of the line

I have a text file containing

/database/sp/NTR_Vlr_Upload.sql
/database/tables/StatsTables.sql
/mib/ntr.mib
/mib/ntr.v2.mib
/scripts/operations/ntr/IMSITracer.ph


i want the last field after "/" removed like

/database/sp/
/database/tables/
/mib/
/mib/
/scripts/operations/ntr/

plz help
Reply With Quote
Forum Sponsor
  #2  
Old 12-11-2006
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,699
Care to read the manpages ? Look at man dirname
Reply With Quote
  #3  
Old 12-11-2006
Registered User
 

Join Date: Jan 2004
Posts: 17
Code:
for line in `cat file.txt`; do dirname $i; done
Reply With Quote
  #4  
Old 12-11-2006
Registered User
 

Join Date: Dec 2006
Location: Maryland
Posts: 144
Are you looking for

cat file | awk -F "/" '{print $NF}'

??

Regds,

Kaps
Reply With Quote
  #5  
Old 12-11-2006
Registered User
 

Join Date: Dec 2006
Location: Maryland
Posts: 144
Ooops , you wanted

cat file | xargs -n1 dirname

Regds,

Kaps
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 04:44 AM.


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