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?
-- thanks, neubyr
On 24/02/11 15:54, 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?
white space or weird chars could be causing problems.
try
find ./ -type f -mtime +15 -print0 | xargs -0 ls
Kal
On Wed, Feb 23, 2011 at 11:54 PM, neubyr neubyr@gmail.com 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
Instead of piping to xargs, try: find . -type f -mtime +15 -exec ls {} ;
On Thu, Feb 24, 2011 at 01:22:41AM -0500, Kwan Lowe wrote:
Instead of piping to xargs, try: find . -type f -mtime +15 -exec ls {} ;
Or get rid of child processes entirely:
find . -type f -mtime +15 -ls
John
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Feb 23, 2011, at 10:26 PM, John R. Dennison wrote:
On Thu, Feb 24, 2011 at 01:22:41AM -0500, Kwan Lowe wrote:
Instead of piping to xargs, try: find . -type f -mtime +15 -exec ls {} ;
Or get rid of child processes entirely:
find . -type f -mtime +15 -ls
Or don't depend on ls for such applications. Use stat or echo instead.
- -- Corey / KB1JWQ
Am 24.02.2011 09:03, schrieb Corey Quinn:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On Feb 23, 2011, at 10:26 PM, John R. Dennison wrote:
On Thu, Feb 24, 2011 at 01:22:41AM -0500, Kwan Lowe wrote:
Instead of piping to xargs, try: find . -type f -mtime +15 -exec ls {} ;
Or get rid of child processes entirely:
find . -type f -mtime +15 -ls
Or don't depend on ls for such applications. Use stat or echo instead.
Why? And if you give good advice, why is the OP seeing the problem?
Rainer
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.
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@gmail.com 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@gmail.com _______________________________________________ CentOS mailing list CentOS@centos.org http://lists.centos.org/mailman/listinfo/centos
centos-bounces@centos.org 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?
Try: find ./ -type f -mtime +15 -print0 | xargs -0 ls
Insert spiffy .sig here
//me ******************************************************************* This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This footnote also confirms that this email message has been swept for the presence of computer viruses. www.Hubbell.com - Hubbell Incorporated**