>>How do I restrict the output of the find command to just the file
> pipe find's output through basename?
Basename does not read stdin:
$ thefile=$(find . -newer trace_file_tmp -print | basename)
basename: too few arguments
Try `basename --help' for more information
>>Here is the code:
>>thefile=$(find . -newer trace_file_tmp -print)
>> if [ -n "$thefile" ] ; then
>> do something
>>Here is the directory it is operating in:
>>-rwxr-xr-x 1 oracle dba 611 Apr 9 11:16 ora_19842_elmcig76.trc
>>-rw-r--r-- 1 oracle dba 0 Apr 29 14:18 test
>>-rw-r--r-- 1 oracle dba 0 Apr 28 14:12 trace_file_tmp
>>With this code I am getting $thefile shown in debug mode:
>>+ [ -n .
>>With $thefile set to . or ./test it is not working like I need it.
What is not working? If you get an error, post it; if you get
unexpected or undesired results, post the actual results as well
as what you want.
Quote:>>How do I restrict find to only "test"?
It's not clear what you want. Do you just want the one file? Or do
you want the leading ./ stripped off? Or both?
If you just want the one file, and it will always be called test,
use that instead of .:
find test -newer trace_file_tmp -print
If you want to strip the leading ./, and have the GNU version of
find -newer trace_file_tmp -printf "%f\n"
Some versions of test (the command, not your file) have the -nt
[ test -nt trace_file_tmp ] && echo test
Chris F.A. Johnson http://cfaj.freeshell.org/shell
My code (if any) in this post is copyright 2004, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License