Today (Saturday) We will make some minor tuning adjustments to MySQL.

You may experience 2 up to 10 seconds "glitch time" when we restart MySQL. We expect to make these adjustments around 1AM Eastern Daylight Saving Time (EDT) US.


Find a set of files in a location


 
Thread Tools Search this Thread
# 1  
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  
You can use the ls command to list the files in a directory:
Code:
ls -l /your_directory_name

# 3  
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  
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  
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
Hello there wonderful people, I am running on Solaris 10 and with the following ksh version: strings /bin/ksh | grep Version | tail -2 @(#)Version M-11/16/88i Suppose I want to copy files that end in _v2 from underneath /dir1/dir2/save directory to /dir1/dir2. Basically, what I’m...... Shell Programming and Scripting
12
Shell Programming and Scripting
Find command to search and delete files older than 1 days at a desired location
Pandee
Hello All, Can someone please help me out in creating the find command to search and delete files older than 1 days at a desired location. Thanks in advance for your help.... Shell Programming and Scripting
3
Shell Programming and Scripting
How to find a existing file location and directory location in Solaris box?
buzzme
Hi This is my third past and very impressed with previous post replies Hoping the same for below query How to find a existing file location and directory location in solaris box... Shell Programming and Scripting
1
Shell Programming and Scripting
Find Set of files
Shanks
All, I am trying to find a set of files, it could be one file OR set of file , all with extension .DAT I need to do some acticity, only if the files exist in a partificular folder like if ; then CntV=`ls $Landing/*.DAT |wc -l` echo "Lst Value " $Cnt...... Shell Programming and Scripting
3
Shell Programming and Scripting
Shell Script for Copy files from one location to another location
allways4u21
Create a script that copies files from one specified directory to another specified directory, in the order they were created in the original directory between specified times. Copy the files at a specified interval.... Shell Programming and Scripting
2
Shell Programming and Scripting

Featured Tech Videos