LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   /usr/local/bin/comp_hist (https://www.linuxquestions.org/questions/linux-newbie-8/usr-local-bin-comp_hist-4175412202/)

ust 06-19-2012 03:48 AM

/usr/local/bin/comp_hist
 
I use find command eg .find / -type f -name "test.log" -exec ls -lt {} \; , the output is the full path eg. /tmp/test.log , can advise if I want to exclude the path , the output is test.log , what can i do ?

thx

tronayne 06-19-2012 06:37 AM

You can use the basename utility:
Code:

find / -type f -name 'test.log' -exec basename {} \; 2>/dev/null
If you're not executing the above as root (with su - or sudo), you may want to add the 2>/dev/null so you don't see all the errors that look like these
Code:

.
.
.
find: `/proc/31910/task/31910/fd': Permission denied
find: `/proc/31910/task/31910/fdinfo': Permission denied
find: `/proc/31910/task/31912/fd': Permission denied
find: `/proc/31910/task/31912/fdinfo': Permission denied
find: `/proc/31910/task/31914/fd': Permission denied
find: `/proc/31910/task/31914/fdinfo': Permission denied
find: `/proc/31910/fd': Permission denied
find: `/proc/31910/fdinfo': Permission denied
.
.
.

Hope this helps some.


All times are GMT -5. The time now is 09:13 AM.