search file
I use the below command to find the file elder than 2 days , it works .
find /var/log -mtime +2 -exec ls -lt {} \; current result ============== /var/log/file1 /var/log/file2 But I found that the result is full path , can advise if I want the result is file name only as below , what can i do ? my desired result ================= file1 file2 |
use this:
basename find /var/log -mtime +2 -exec ls -lt {} \; |
To format the output of find in various ways, look at using -printf.
find /var/log -mtime +2 -printf '%f\n' |
Pipe the result into SED....
eg : sed 's%^.*/%%' Replaces any number of characters from the beginning of the line, up to and including the last instance of "/", with an empty character. "%" is used as the delimiter to allow "/" to be in the Regex. This will do the same thing: sed 's/^.*\///' |
All times are GMT -5. The time now is 06:08 PM. |