Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Kernel 2.6.21.5, GNU (Slackware 12.0).
find 4.2.31
xargs 4.2.31
ls 6.9
bash 3.1.17
Hi:
Code:
find . -name *.htm* -print0|xargs -0 ls
outputs file name f2.
Clearly, '*.htm*' can't be matched by 'f2'. In the dir I'm running the command in, find does not find any matching file. In turn, then, xargs delivers 0 arguments to ls which makes ls to output the whole directory listing. But the intended command purpose I think is evident. I only need to rule out the particular case just described. Any suggestions? Regards.
Thanks for your reply. I think this will describe it:
Quote:
I want to search an entire subtree of /, in the file system, for all files, with extension html, created on the hard disk. In addition, these have to be the last five created.
I think I could split the problem into two parts: (a) Forget about the last condition. Then this is a job for the find command. (b) Sort the output of find using the date as the key, then use 'head' to print the desired output.
But even two such simple steps are enough to justify the writing of a shell script. And here lies my weakness. My script writing knowledge is rudimentary.
What's the final purpose? Well, I lately saved four or five LQ pages onto disk containing information I consider valuable to me. But I don't exactly remember where on the disk. So...
Then: either the problem posed is really of a very simple nature or it is not, in the latter case a script being mandatory. Any suggestion will be welcome. Thank you for reading.
EDIT: one of the algorithm drawbacks (the one described above) is that find may be running a great deal of time. My machine resources (RAM and CPU speed are low) are scarce and there possible are a large number of HTML files on the disk.
I see you've added an action to the find command. If the subtree in question is small enough then the command will terminate execution after a few minutes [but what command?]. Regards.
Yes. After receiving post #2 I limited myself to describe the scenario but I did not do any thinking. But after sending #3 I saw find was enough to do the main job. Now I'll play a little under the guidelines given by you. Thanks a lot.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.