UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 23rd, 2005, 04:16 AM
sunvsunv sunvsunv is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 139 sunvsunv User rank is Corporal (100 - 500 Reputation Level)sunvsunv User rank is Corporal (100 - 500 Reputation Level)sunvsunv User rank is Corporal (100 - 500 Reputation Level)sunvsunv User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 16 h 10 m 55 sec
Reputation Power: 7
Help with find command

I want to find out all the files whose extension is .java or .jsp or .html from a particular directory.

For example, find $HOME -name '*.jsp' command would search for only jsp files.

This way I want to find out all the files whose extension is java, jsp or html.

Any clues on this would be appreciated.

Thanks for your time.

Reply With Quote
  #2  
Old February 23rd, 2005, 08:55 AM
zlutovsky zlutovsky is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Location: Prague, Czech Rep.
Posts: 117 zlutovsky User rank is Corporal (100 - 500 Reputation Level)zlutovsky User rank is Corporal (100 - 500 Reputation Level)zlutovsky User rank is Corporal (100 - 500 Reputation Level)zlutovsky User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 22 h 42 m 44 sec
Reputation Power: 6
Quote:
Originally Posted by sunvsunv
I want to find out all the files whose extension is .java or .jsp or .html from a particular directory.

For example, find $HOME -name '*.jsp' command would search for only jsp files.

This way I want to find out all the files whose extension is java, jsp or html.

Any clues on this would be appreciated.

Thanks for your time.


Most simple solution:

find $HOME -name '*.java' >/tmp/list
find $HOME -name '*.jsp' >>/tmp/list
find $HOME -name '*.html' >>/tmp/list

Now you can for instance:

cat /tmp/list | cpio -ovcaB >/dev/your_tape_device

Regards

Reply With Quote
  #3  
Old February 23rd, 2005, 09:32 AM
gruntz gruntz is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 53 gruntz User rank is Private First Class (20 - 50 Reputation Level)gruntz User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 22 h 39 m 25 sec
Reputation Power: 5
Quote:
Originally Posted by zlutovsky
find $HOME -name '*.java' >/tmp/list
find $HOME -name '*.jsp' >>/tmp/list
find $HOME -name '*.html' >>/tmp/list


just to add to zlutovsky's

You can also use -o (or) like
\(-name '*.java' -o -name '*.jsp' -o ...... \) instead of 3 line

-a(and) is implied or default

Reply With Quote
  #4  
Old February 23rd, 2005, 12:01 PM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,089 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 5 Days 3 h 40 m 34 sec
Reputation Power: 9
VERY simple and imo NOT the solution :

Quote:
find $HOME -name '*.java' >/tmp/list
find $HOME -name '*.jsp' >>/tmp/list
find $HOME -name '*.html' >>/tmp/list

Q: who said, you can write /tmp/list ?
suppose /tmp/list is still there owned by an other user NOT in your group and and and
the ONLY safe place for tmps is NOT /tmp but $HOME

gruntz way is better
an alternative to that would be
find . ¦ egrep "...¦...¦..." (NOTA: i prefer sed)
but for this you should read manuals, do it!

a last remarque zlutovsky

not only you are running 3 times find, but you also open(and close)
3 times the same fd

the problem is: today our hw is good, do that on a 30years old
NCRtower1632, you will undestand what i mean.
__________________
working on Solaris[5-9], preferred languages french and C.

Reply With Quote
  #5  
Old April 12th, 2005, 07:54 AM
sunvsunv sunvsunv is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 139 sunvsunv User rank is Corporal (100 - 500 Reputation Level)sunvsunv User rank is Corporal (100 - 500 Reputation Level)sunvsunv User rank is Corporal (100 - 500 Reputation Level)sunvsunv User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 16 h 10 m 55 sec
Reputation Power: 7
Thanks to all.

Reply With Quote
  #6  
Old July 27th, 2005, 01:34 PM
NPRao NPRao is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: Pacific NW, USA
Posts: 26 NPRao User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 23 m 16 sec
Reputation Power: 0
Send a message via AIM to NPRao
Quote:
Q: who said, you can write /tmp/list ?
suppose /tmp/list is still there owned by an other user NOT in your group and and and
the ONLY safe place for tmps is NOT /tmp but $HOME

Make a unique file -
Quote:
ZDATE=`/usr/bin/date +%Y%m%d%H%M%S`
TEMPFILE=$HOME/$PROGNAME.$ZDATE

Reply With Quote
  #7  
Old December 15th, 2005, 05:58 AM
sunvsunv sunvsunv is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2004
Posts: 139 sunvsunv User rank is Corporal (100 - 500 Reputation Level)sunvsunv User rank is Corporal (100 - 500 Reputation Level)sunvsunv User rank is Corporal (100 - 500 Reputation Level)sunvsunv User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 16 h 10 m 55 sec
Reputation Power: 7
Quote:
Originally Posted by NPRao
Make a unique file -
even if you could generate a unique file, we would always not have a write permission to /tmp directory. It is always better to place in $HOME.

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > Help with find command


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway