Re: ls returns file doesn't exist, find finds it??

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Thanks for the replies everyone.

Les, you were right about meta-characters. The file name contains
"double-quotes" (bad log4j config) and that's causing the problem.
e.g. /opt/apps/tomcat/logs/apache.log\".-2010-09-24\"
The ls command works fine after escaping double quotes:  \" .

My objective was to delete files matching find-pattern using 'xargs
rm'. I wanted to do 'ls' before I delete these files permanently. I
guess I can use 'find -delete' action instead which is working fine.

--
neubyr.


On Thu, Feb 24, 2011 at 7:59 AM, Les Mikesell <lesmikesell@xxxxxxxxx> wrote:
> On 2/23/11 10:54 PM, neubyr wrote:
>> Howdy,
>>
>> I am getting some errors with find and ls command - such that find is
>> able to see a file whereas ls says the file doesn't exist. Initially I
>> was trying find and ls together as:
>> # find ./ -type f -mtime +15 | xargs ls
>>
>> Similar behavior is seen even when I execute both commands separately.
>> Any thoughts on what might be wrong here?
>
> Can you give an example of a path that find returns and the output of
> ls -l 'that_path_in_quotes'
> My first guess is that you have shell metacharacters (like spaces) in the file
> or directory names that the shell parses/expands if you don't quote them.  Using
> the GNU --print0 extension to find and the matching -0 option to xargs might fix it.
>
> --
>   Les Mikesell
>    lesmikesell@xxxxxxxxx
> _______________________________________________
> CentOS mailing list
> CentOS@xxxxxxxxxx
> http://lists.centos.org/mailman/listinfo/centos
>
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos



[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux