The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Excluding directories with find x96riley3 UNIX for Dummies Questions & Answers 3 04-08-2009 04:12 AM
"find command" to find the files in the current directories but not in the "subdir" swamymns Shell Programming and Scripting 9 07-22-2008 11:23 AM
to find a file in set of directories jazz High Level Programming 3 11-16-2005 09:36 AM
Find directories not containing foo, and copy foo to them dkaplowitz Shell Programming and Scripting 6 06-29-2005 08:50 AM
Find wildcard .shtml files in wildcard directories and removing them- How's it done? Neko UNIX for Dummies Questions & Answers 1 06-27-2001 09:06 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-01-2005
steiner steiner is offline
Registered User
  
 

Join Date: Jul 2003
Location: Hambach - France
Posts: 29
Find files in Directories

Hello,

We have in a file a list of the path of files from one server.
We want to search if these files exist on another server , but the path on this new server isn't the same.

We want to use the command "awk" but there isn't the god way.

Example:
on server 1 in a file : listServer1.txt we have
/toto/titi/file.txt
/toto/titi/exam.txt

On server 2 we want to search on
/bbb/gggg/file.txt
/bbb/gggg/exam.txt

Can someone help us with this little problem

Thanks...
  #2 (permalink)  
Old 04-01-2005
Just Ice's Avatar
Just Ice Just Ice is offline Forum Advisor  
Lights on, brain off.
  
 

Join Date: Mar 2005
Location: in front of my computer
Posts: 637
On the remote server, find the directory that file.txt resides in ...

you can ...
Code:
find / -name "file.txt" -exec ls {} \;
or if the file path will always be /dir/subdir/file.txt, you can ...
Code:
ls -l /*/*/file.txt
  #3 (permalink)  
Old 04-02-2005
sglinux sglinux is offline
Registered User
  
 

Join Date: Mar 2005
Posts: 6
find . -type f -print | grep file.txt
find * -type f -print | grep file.txt
find / -type f -print | grep file.txt
  #4 (permalink)  
Old 04-02-2005
zazzybob's Avatar
zazzybob zazzybob is offline Forum Advisor  
Registered Geek
  
 

Join Date: Dec 2003
Location: Melbourne, Australia
Posts: 2,100
Quote:
Originally Posted by sglinux
find . -type f -print | grep file.txt
find * -type f -print | grep file.txt
find / -type f -print | grep file.txt
No need for the grep....

find / -name "file.txt" -type f -exec ls -l {} \;

Looking at your input file, s script such as the following should get you started....
Code:
#!/bin/ksh

while read line; do
   filename=${line##*/}
   wcho "Finding filename: ${filename}"
   find . -name "${filename}" -type f -exec ls -l {} \; 2>/dev/null
done < filelist

exit 0
Cheers
ZB
  #5 (permalink)  
Old 04-02-2005
Just Ice's Avatar
Just Ice Just Ice is offline Forum Advisor  
Lights on, brain off.
  
 

Join Date: Mar 2005
Location: in front of my computer
Posts: 637
looking for all the files in the list will confirm that you have the right directory but ... if there's one file in your list that you know does not exist anywhere else --- just find the directory that file resides in and you're there already ...
Closed Thread

Bookmarks

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

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




All times are GMT -4. The time now is 07:48 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0