List versus find command

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers List versus find command
# 1  
Old 01-09-2014
List versus find command


My OS is SunOS mymac1 5.10 Generic_148888-04 sun4v sparc SUNW,SPARC-Enterprise-T5220

When i cd /var/output
ls -ltr *.css

It yields the output in less than a second. While
find /var/output  -type f -name "*.css"

does not complete for a while.
find /var/output  -type f *.css
find: bad option current_017.css
find: [-H | -L] path-list predicate-list

Can you please let me know what is incorrect and also how can i add the date to the current find command so that it lists only those .css files that match that date [yyyy-mm-dd]

Thank you !!

Last edited by mohtashims; 01-09-2014 at 11:15 AM..
# 2  
Old 01-09-2014
The find command will be searching down every directory under /var/output for matching files. This can be a good thing if that's really what you want.

Have a read of the man page for find The command you have entered second has two problems. Firstly it does not say that *.css is going to be a file name and secondly, the shell will expand this before actually executing the find

If you have a file current_017.css then this will be used in the find command.

I would suggest you use:-
find /var/output -type f -name "*.css"

as you have listed, if this is really what you want.

For matching on a date, then you have a number of options all listed on the amnual pages, such as -newer & -mtime and you might need to be a little creative to get the listing you want.

If you can create to files, you can search between their timestamps:-
touch -mt 201401090000 /tmp/myfind.start
touch -mt 201401092359 /tmp/myfind.end
find /var/output -type f -name "*.css" -newer /tmp/myfind.start ! -newer /tmp/myfind.end

Does that help, or give you something else to consider?

This User Gave Thanks to rbatte1 For This Post:
# 3  
Old 01-09-2014
You can try this:

Touch two files one with the date you're looking for and the other dated the next day:

i.e. January 09, 2014
touch -t "20140109000" /tmp/file1
touch -t "20140110000" /tmp/file2

Then fun the find command:
find . -name '*.css' -type f -newer /tmp/file1 ! -newer /tmp/file2 -ls

Late to the party again... ;-)
# 4  
Old 01-09-2014
I don't want to drill down sub folders. What should be the command then ?

Last edited by mohtashims; 01-09-2014 at 12:31 PM..
# 5  
Old 01-09-2014
You can try using the -prune option to restrict the search to the current directory:

find . ! -name . -prune -type f

# 6  
Old 01-09-2014
Originally Posted by in2nix4life
You can try using the -prune option to restrict the search to the current directory:

find . ! -name . -prune -type f

Can't i give the complete folder name and search just that directory ? Becoz i am not in the current directory so i don't want to use the dot(.)

Also, the find does not yield any output when the ls does !!

find . -prune  -type f -name "*.css"
No Output !!

ls -ltr *.css
-rw-rw----   1 5000032 Dec 30 11:59 P010111.css
-rw-rw----   1 5000032 Jan  2 21:19 P013461.css
-rw-rw----   1 5000032 Jan  8 09:04 P020367.css
-rw-rw----   1 5000032 Jan  8 14:12 P020427.css

Last edited by mohtashims; 01-09-2014 at 01:03 PM..
# 7  
Old 01-09-2014
How about:-
cd /var/output
find . ! -name . -prune -type f ........................
cd -


Last edited by rbatte1; 01-09-2014 at 12:58 PM.. Reason: Added signature lines
This User Gave Thanks to rbatte1 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find command to find a word from list of files

I need to find a word '% Retail by State' in the folder /usr/sas/reports/RetailSalesTaxallocation. When I tried like below, -bash-4.1$ cd /usr/sas/reports/RetailSalesTaxallocation -bash-4.1$ find ./ -name % Retail by State find: paths must precede expression: Retail Usage: find ... (10 Replies)
Discussion started by: Ram Kumar_BE
10 Replies

2. Shell Programming and Scripting

List last 1 hour files with out FIND command

Hi Friends, Can we have an alternate command to list last 1hour files with out FIND command? Thanks Suresh (6 Replies)
Discussion started by: suresh3566
6 Replies

3. UNIX for Dummies Questions & Answers

Code to list the files of find command

hi, i want to list the files from the below find commands output. find ./* -name "*.txt" -type f -mtime +10 will give the output like ./a.txt but i need the output in the format like (ls -lrt a.txt ) -rw-rw-rw- 1 srea nast 5 May 23 07:34 a.txt i used xargs for the... (4 Replies)
Discussion started by: msathees
4 Replies

4. Shell Programming and Scripting

How to list the files based on the modification time using the find command?

Hi All, I need to list the files based modification time of the files from a directory, I cannot use "ls -t" as there are lot of files, which "ls" command cannot handle. New files will land there daily. So iam looking for an alternative through "find"command. All suggestions are welcomed. ... (6 Replies)
Discussion started by: Kesavan
6 Replies

5. Shell Programming and Scripting

how assign the O/p of find command to a list.

i want to take the o/p of find command into a list like in java. can anyone help me regarding this. (10 Replies)
Discussion started by: dineshmurs
10 Replies

6. Shell Programming and Scripting

Help with find command and list in a long format each found file

The purpose of those comands are to find the newest file in a directory acvrdind to system date, and it has to be recursively found in each directory. The problem is that i want to list in a long format every found file, but the commands i use produce unexpected results ,so the output lists in a... (5 Replies)
Discussion started by: alexcol
5 Replies

7. Shell Programming and Scripting

command find returned bash: /usr/bin/find: Argument list too long

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)
Discussion started by: yacsil
1 Replies

8. UNIX for Dummies Questions & Answers

Question about DOS versus Unix Command?

Okay here is a DOS comparison. When I search for a file in DOS and I was not sure what directory it was in then I would put dir /s/o/p filename the s would tell it to look in every directory including subs, the o would sort it alphabetically and the p would limit the display to one page at a... (1 Reply)
Discussion started by: wmosley2
1 Replies

9. UNIX for Dummies Questions & Answers

CTRL+H versus ^? versus BACKSPACE

Hi Gurus! I recently got my shell account (HP UX v11) created by our sysadmin and am having problem deleting with the backspace key. After doing some reading, I believe I need to enter a custom "STTY..." statement in my profile. Can someone please help me with the correct "STTY" sequence... (3 Replies)
Discussion started by: alan
3 Replies

10. UNIX for Dummies Questions & Answers

solaris2.6 command to find/list system configuration

Hi. What command can be used to determine the system configuration. For example I want to find out how much CPU, how much memory, what CPU and 233mhz or 400mhz, etc. Please help.... (4 Replies)
Discussion started by: subhransu
4 Replies
Login or Register to Ask a Question