'find' question


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting 'find' question
# 1  
Old 03-27-2010
'find' question

hey guys!

I need to find in a specific directory and its sub-directories a file thats passed has a argument, and print it has like a ls -l command! the problem is how do i print has a ls command but instead only the file name in the end, also the directory where its insered!


ex:

Want to find in a specific dir a file named hello.txt, but this dir is inside another one thats the "mainDir"!
and the output has to be like a ls-l output but instead of only:

drwxr-xr-x 3 kk kk 4096 date time hello.txt
drwxr-xr-x 3 kk kk 4096 date time insiredDir/hello.txt


So my idea was to do a: find ~/mainDir -name 'roflmao.txt' > help.txt
putting all existing files paths inside this txt
Then do a while to grab all paths 1 by 1 and and do a ls -l (since it has to be outputted that way). So far so good! but the outputted ls has i said only has to give the file that i looked for and its insired dir like in ex above!

Any suggestion of doing another way or ...? :x

Thanks in advanced!
# 2  
Old 03-27-2010
MySQL

Did you meant like this?

Code:
 
find -type f -name '*test*' -exec ls -lh {} \;

Code:
-rw-r--r-- 1 root root 0 Mar 26 08:42 ./feed/3teste33
-rw-r--r-- 1 root root 0 Mar 26 08:42 ./feed/33teste33
-rw-r--r-- 1 root root 0 Mar 26 08:42 ./11teste11
-rw-r--r-- 1 root root 0 Mar 26 09:22 ./this/11teste11
-rw-r--r-- 1 root root 0 Mar 26 09:22 ./this/22teste22
-rw-r--r-- 1 root root 0 Mar 26 09:22 ./this/test1
-rw-r--r-- 1 root root 0 Mar 26 09:22 ./this/3teste33
-rw-r--r-- 1 root root 0 Mar 26 09:22 ./this/33teste33
-rw-r--r-- 1 root root 0 Mar 26 09:22 ./this/test2
-rw-r--r-- 1 root root 0 Mar 26 08:42 ./bound/22teste22
-rw-r--r-- 1 root root 0 Mar 26 08:30 ./filezip/test1
-rw-r--r-- 1 root root 0 Mar 26 08:30 ./filezip/test2

# 3  
Old 03-27-2010
yeah that worked! cheers!

i was trying with

find -maxdepth 2 -type f -name "*teste*" | xargs ls -l

but that works better since of depth is only good for some speccific depth files =)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Question on ls and find

Hi, Is there an option to run ls to only show files owned by the current user? Currently doing ls | awk | grep for the user. If I use find and -user ${username}, I am getting Permission denied messages on some directories and am currently re-directing those messages as 2>/dev/null. Is that... (2 Replies)
Discussion started by: newbie_01
2 Replies

2. UNIX for Dummies Questions & Answers

A question on find command

I need to find all files with file names starting with alert and ending with .log I mean, the following files should be returnrned alertTST.log alertabcdefgh.log How can i do this ? (4 Replies)
Discussion started by: kraljic
4 Replies

3. Shell Programming and Scripting

find command question

Hi all, I want to use find to 'find' files older than a file. The command I have come up with so far is find . -type f ! -newer filename -print | grep -v filename If I dont use the -v then the filename is included in the output is there a better way of formulating this command... (1 Reply)
Discussion started by: jonnyd
1 Replies

4. UNIX for Dummies Questions & Answers

Find Command Question

I was using this find command to search for this string find /usr/reports -name '*.txt' -type f -exec grep -l tbl_out:add_19 {} \; > /usr/work/junk.txt My question is, if I want to search another type of file extension besides '*.txt' how can I include it on the same line to say something... (5 Replies)
Discussion started by: NycUnxer
5 Replies

5. UNIX for Dummies Questions & Answers

Dumb find question

All, For some reason I can't figure out why I can't wildcard my find statement to check for anything with a wildcard after. I can before the -name but not after. ie. find . -name *test works but find . -name test* gives me the error: find: paths must precede expression Usage: find ... (1 Reply)
Discussion started by: markdjones82
1 Replies

6. Shell Programming and Scripting

find . -name question

Not sure if I'm missing it, but I'm looking on the find man page, but can't find it. Here is what I'm doing find . -name "log_*" -type f -mtime +8 -exec rm {} \; How do I tell man to find all files matching that pattern, but only ones that end with a numeric character. I thought it was... (4 Replies)
Discussion started by: cbo0485
4 Replies

7. UNIX for Dummies Questions & Answers

Question about 'find'

I have a file, but I don't know this file is stored in which directory, if I use 'find' command to search this file, is it work? which option I use? find filename? (2 Replies)
Discussion started by: wendyz
2 Replies

8. Shell Programming and Scripting

Question on Find Utility

Hi Guys, Do you know how can I find files with modificatioin time less than 30 MINUTES using the find utility? Or if u have any other mechanism to find it using script, I'll appreciate it. Thanks! (5 Replies)
Discussion started by: marlonus999
5 Replies

9. UNIX for Dummies Questions & Answers

find ...question.

:D i am looking through the man pages of the find command and I have found the -printf and fprintf section.. . I tried this command and got an error find -follow -newer 'date.file' -printf %f file1 i keep getting a %f in directory listing and no input into file1 according to the manpages %f... (2 Replies)
Discussion started by: moxxx68
2 Replies

10. UNIX for Dummies Questions & Answers

find question

Is it possible for find to match on multiple arg's. Basically, I would like to be able to match on name and atime. Basically I want something like: find . -atime +31 <AND> -name *.log -exec rm -f {} \; Thanks (2 Replies)
Discussion started by: 98_1LE
2 Replies
Login or Register to Ask a Question