Find a set of files in a location


 
Thread Tools Search this Thread
# 1  
Old 01-10-2013
Power Find a set of files in a location

Hi, I am new to Unix. I need a script to check some 74 files are present in a particular location or not .
# 2  
Old 01-10-2013
You can use the ls command to list the files in a directory:
Code:
ls -l /your_directory_name

# 3  
Old 01-10-2013
Thanks for ur response..using this command that u provided i can get all the files present in that location.. can i use find command to search my file..can i give all the names of these 74 files in one command and find it ?
# 4  
Old 01-10-2013
You could put the file names your looking for in a file(1 on each line) and then use the find command to find them:

Code:
for f in `cat my_file_names.txt`
do
  find / -name "$f" 2>/dev/null
done

# 5  
Old 01-11-2013
This means running find 74 times. Why not ls them all and then grep with the names file:
Code:
ls -l /your_directory_name | grep -f my_file_names.txt

You could add a wc (word count) to check the 74, or you could compare the output to your names file to identify single missing files.
Actually, this will take ls's output as the pattern file and print the missing files for you:
Code:
ls|grep -vf - names


Last edited by RudiC; 01-11-2013 at 05:00 AM.. Reason: quick solution added
 

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
Use find with cp and sed in ksh to copy files to a slightly different location ejianu Shell Programming and Scripting 12 10-20-2016 05:47 PM
Help needed with shell script to search and replace a set of strings among the set of files Amulya Shell Programming and Scripting 10 02-27-2014 02:34 AM
Find cpu location beta17 Red Hat 1 09-04-2013 11:15 AM
Find the list of files with a set of Users sethmj UNIX for Advanced & Expert Users 6 06-21-2013 01:11 PM
Help with copying the list of files from one location to other location GG2 Shell Programming and Scripting 1 06-10-2013 03:45 PM
Find command to search and delete files older than 1 days at a desired location Pandee Shell Programming and Scripting 3 01-16-2013 06:29 AM
How to find a existing file location and directory location in Solaris box? buzzme Shell Programming and Scripting 1 01-10-2013 09:13 PM
Find Computer Location budiantho_indra Red Hat 5 10-06-2012 01:33 PM
Finding compound words from a set of files from another set of files shoaibjameel123 Shell Programming and Scripting 2 08-27-2011 02:26 AM
Find Set of files Shanks Shell Programming and Scripting 3 06-30-2011 11:35 AM
Help on Moving files from one location to another location kpagadala Shell Programming and Scripting 4 04-09-2010 03:45 AM
Shell Script for Copy files from one location to another location allways4u21 Shell Programming and Scripting 2 01-21-2010 04:26 PM
Transfer files from one location to another location KiranKumarKarre Shell Programming and Scripting 1 05-04-2009 04:57 AM
copy files from one location to similar location pharos467 UNIX for Advanced & Expert Users 1 09-21-2008 01:21 PM