Find files in Directories


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find files in Directories
# 1  
Old 04-01-2005
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  
Old 04-01-2005
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  
Old 04-02-2005
find . -type f -print | grep file.txt
find * -type f -print | grep file.txt
find / -type f -print | grep file.txt
# 4  
Old 04-02-2005
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  
Old 04-02-2005
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 ...
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 excluding directories and some files

hello. I try to print a list of files but excluding some directories and some files. I would like to write a command for : find "from_dir" "ignore dir1, dir2, ..." "ignore file1, file2,...." "where file are older than 2017-02-03T06:00:00" Note that "DO_IT" is a local function in the script... (5 Replies)
Discussion started by: jcdole
5 Replies

2. Shell Programming and Scripting

Find common files between two directories

I have two directories Dir 1 /home/sid/release1 Dir 2 /home/sid/release2 I want to find the common files between the two directories Dir 1 files /home/sid/release1>ls -lrt total 16 -rw-r--r-- 1 sid cool 0 Jun 19 12:53 File123 -rw-r--r-- 1 sid cool 0 Jun 19 12:53... (5 Replies)
Discussion started by: sidnow
5 Replies

3. UNIX for Dummies Questions & Answers

Loop over certain user directories and find files

Hello I have user directories that contain /temp directory. Example folders: /user1/temp/ /user2/temp/ /user3/temp/ How can i loop over all user directories and find all files only in their /temp folder? Thanks a lot for help! (3 Replies)
Discussion started by: flavius42
3 Replies

4. UNIX for Dummies Questions & Answers

Find Files In A List with known Partial Directories

First I'm new to Linux and have used the find command pretty often but this is where I've hit a snag. I have a file that contains 3500 files that I want to find and then eventually copy to my own directory (these files are all on a shared directory at work atm). Our work computer are huge and... (2 Replies)
Discussion started by: Myrona
2 Replies

5. UNIX for Advanced & Expert Users

Find all files in the current directory excluding hidden files and directories

Find all files in the current directory only excluding hidden directories and files. For the below command, though it's not deleting hidden files.. it is traversing through the hidden directories and listing normal which should be avoided. `find . \( ! -name ".*" -prune \) -mtime +${n_days}... (7 Replies)
Discussion started by: ksailesh1
7 Replies

6. Shell Programming and Scripting

Find only files/directories with different permissions/owners

My git post-update has the following lines in it to make sure the permissions are set right: find /usr/local/apache/htdocs -type d -print0 | xargs -0 chmod 755 find /usr/local/apache/htdocs -type f -print0 | xargs -0 chmod 644 chown -R apache:apache /usr/local/apache/htdocsThe only problem is... (5 Replies)
Discussion started by: dheian
5 Replies

7. Shell Programming and Scripting

Script to go Into Directories and Find/Delete files

I have a task, I usually do manually, but with growing responsibilities I tend to forget to do this weekly, I want to write a script that automates this, but I cant seem to work it out in my head, I have the shell of it out, but need help, and you guys have helped me with EVERY problem I have... (5 Replies)
Discussion started by: gkelly1117
5 Replies

8. Shell Programming and Scripting

Find Files with a input in directories

So i have directories that store logs, 1 directorie for each day, with the name like this : 2012_07_01/ 2012_07_02/ and for each directorie we have the logs, inside them lives the logs for that day, and every log have this name pattern : ... (2 Replies)
Discussion started by: drd0spt
2 Replies

9. Homework & Coursework Questions

Find and delete empty files and directories

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Need to make a script, to remove all empty files and folders from current category. It also should show the name... (2 Replies)
Discussion started by: Itixop
2 Replies

10. UNIX for Advanced & Expert Users

find -type d returning files as well as directories

Can anyone see why the following command returns all files and not just the directories as specified? find . -type d -exec ls -F {} \; Also tried find . -type d -name "*" -exec ls -F {} \; find . -type d -name "*" -exec ls -F '{}' \; -print Always returns all files :-\ OS is... (2 Replies)
Discussion started by: tuns99
2 Replies
Login or Register to Ask a Question