The UNIX and Linux Forums  

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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
filtering the logs prvnrk Shell Programming and Scripting 5 04-08-2008 06:57 PM
awk and sed filtering invinzin21 Shell Programming and Scripting 2 01-10-2008 11:56 PM
port filtering ujjwalmohan HP-UX 0 11-25-2007 09:18 PM
awk filtering ? varungupta UNIX for Advanced & Expert Users 4 09-16-2007 11:55 PM
List grep results slire UNIX for Dummies Questions & Answers 14 10-31-2006 07:42 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-10-2007
Registered User
 

Join Date: Mar 2007
Posts: 8
filtering list results

I created a large file list using:

find . -type f -mtime +540 > test2.txt

..which searched recursively down the directory tree searching for any file older than 540 days.

I would like to filter the results removing the directory name and the "/" character, resulting in only a list of the filenames, i.e.:

directoryName/filename

changed to,

filename


I think using sed or awk would work, but not entirely sure how to proceed.

Thanks!
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 10-10-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
man basename
Reply With Quote
  #3 (permalink)  
Old 10-10-2007
Registered User
 

Join Date: Sep 2006
Posts: 1,543
if you have GNU find
Code:
find . -type f -mtime +540 -printf "%f\n"
Reply With Quote
  #4 (permalink)  
Old 10-10-2007
Registered User
 

Join Date: Mar 2007
Posts: 8
yeah, this seemed to work, thanks!

find . -type f -mtime +540 | basename */* * > fileList.txt
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:24 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 Global Fact Book

Content Relevant URLs by vBSEO 3.2.0