If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > Unix Shell Scripts > Script (to do the same as find)

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-18-06, 09:05
Apuokas Apuokas is offline
Registered User
 
Join Date: Jan 2006
Location: everywhere where u can find computer and internet
Posts: 4
Script (to do the same as find)

Hello there. I have a task to make a unix shell script that does the same thing as find command. I should implement only -name -exec -print and -depth parameters.

First step, is there a way to list all the files without using find comand?

Can somebody help me with that?

Tons'a'thanks
Reply With Quote
  #2 (permalink)  
Old 01-18-06, 10:51
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
Cool



man ls



__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
  #3 (permalink)  
Old 01-18-06, 11:06
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
Cool



man ls



__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
  #4 (permalink)  
Old 01-18-06, 16:31
Apuokas Apuokas is offline
Registered User
 
Join Date: Jan 2006
Location: everywhere where u can find computer and internet
Posts: 4
Yep...
"ls -R"
I figured that out, but wat to do with that list?

Any comments?

Thanks
Reply With Quote
  #5 (permalink)  
Old 01-18-06, 16:49
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
Cool


Do the same thing as find command, depending on the option(s):

For -name, you can use "grep"
For -exec, just execute command replacing the {} with the dir/file name.
For -print, echo the result.
and for -depth, it's going to be a bit more difficult to simulate.

Good luck!

PS: You may want to use: ls -1R

__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
  #6 (permalink)  
Old 01-18-06, 17:09
Apuokas Apuokas is offline
Registered User
 
Join Date: Jan 2006
Location: everywhere where u can find computer and internet
Posts: 4
I thought that grep would be the best choise to take out the things from the list, but how do I do that?

e.g.

.:
file1
file2
file3

./dir1:
file1
file2
file3

./dir2/dir3:
file1
file2
file3

if the output is like this, what pattern should I put to grep to take out the files i don't need, but still keep the dir's name, to locate the file?

Millions of thanks...
Reply With Quote
  #7 (permalink)  
Old 01-20-06, 13:20
LKBrwn_DBA LKBrwn_DBA is offline
Registered User
 
Join Date: Jun 2003
Location: West Palm Beach, FL
Posts: 2,456
Smile


man grep

To exclude items do: grep -v {pattern}


__________________
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On