I'm wondering why this command does not work, at least, as I expect:
I expect that it list all files older than 7 days, with all information (ls -l). However it prints all files regardless of the date. Using -exec instead of '| xargs' has the same behavior.
On the other hand this command, that deletes all files older than 7 days works perfectly:
Why 'same' command works with rm and it doesn't with ls?
Is it possible to print all information (ls -l) of files older than X days?
Looks odd to me too - did you check it on another (similar) box?
You are right. I've just checked it in my own Ubuntu at home and it works.
I don't know which command in CentOS has the problem. It is strange thing, isn't it?
Quote:
Originally Posted by methyl
Is "ls" and alias ?
Try the full path /usr/bin/ls .
Yes, I already tried it. But it didn't work either.
Thanks both. I'll try to find out why CentOS has such strange behavior. I'll also check it in a Redhat.
Assuming that the O/P Operating System is working properly, this would be better with large numbers of files or where there are files containing space characters:
Ps: This Shell construct also works when there are no files.
Scratch this... I missed that you had the -type f option in the OP.
There's a good chance that '.' (the current directory) is also matching the search criteria (it too hasn't been updated recently) and as a result the list command for that
will display the current directory. An easy test would be to run the command in the directory with out the pipe and see if . is listed. Solution would be to add the -d option to ls, or use
if that is acceptable and/or your flavour of find supports the -ls option.
Last edited by agama; 07-28-2010 at 12:05 AM..
Reason: Clarification
Hello,
This is a bit complicated for me.
My scenario in MyFile:
Search string1,
When string1 is found, grep the line containing string1, go back over that line in upward direction and grep the first line containing string2.
Here is an example:
MyFile
His email address... (17 Replies)
I need assistance with following requirement, I am new to Unix.
I want to do the following task but stuck with file creation date(sysdate)
Following is the requirement
I need to create a script that will read the abc/xyz/klm folder and look for *.err files for that day’s date and then send an... (4 Replies)
Hi Friends,
Please help me to sort out this problem, I am running this in centos o/s and whenever I run this script I am getting "find: missing argument to `-exec' " but when I run the same code in the command line I didn't find any problem. I am using perl script to run this ... (2 Replies)
Hi all ,
I'm new to unix
I have a checked project , there exists a file called xxx.config .
now my task is to find all the files in the checked out project which references to this xxx.config file.
how do i use grep or find command . (2 Replies)
Hello everyone,
first post here, trying to learn scripting on my own and this forum as been really helpful so far. I made few little scripts working great but I m facing some problems with RE.
I have a bunch of files in many subdirectories called *001.ext *002.ext OR simple *.ext or *01.ext... (7 Replies)
I need to find whether there is a file named vijay is there or not in folder named "opt" .I tried "ls *|grep vijay" but it showed permission problem.
so i need to use find command (6 Replies)
Yes , I have to find a file in unix without using any find or where commands.Any pointers for the same would be very helpful as i am beginner in shell scritping and need a solution for the same.
Thanks in advance.
Regards
Jatin Jain (10 Replies)
Hello,
I create a file touch 1201093003 fichcomp
and inside a repertory (which hava a lot of files) I want to list all files created before this file :
find *.* \! -maxdepth 1 - newer fichcomp but this command returned bash: /usr/bin/find: Argument list too long
but i make a filter all... (1 Reply)