Find a set of files in a location


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Find a set of files in a location
# 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
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Use find with cp and sed in ksh to copy files to a slightly different location

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... (12 Replies)
Discussion started by: ejianu
12 Replies

2. UNIX for Advanced & Expert Users

Find the list of files with a set of Users

Hello all, I want to find the files for certain users. I cant make the or condition work in this instance. I've tried the code below but it didnt worked. Any input on how to get the list for all files for this users. find . -type f -user abc134 -o -user xyz345 -o bce483 -exec ls... (6 Replies)
Discussion started by: sethmj
6 Replies

3. Shell Programming and Scripting

Help with copying the list of files from one location to other location

A) I would like to achive following actions using shell script. can someone help me with writing the shell script 1) Go to some dir ( say /xyz/logs ) and then perform find operation in this dir and list of subdir using find . -name "*" -print | xargs grep -li 1367A49001CP0162 >... (1 Reply)
Discussion started by: GG2
1 Replies

4. Shell Programming and Scripting

Find command to search and delete files older than 1 days at a desired location

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. (3 Replies)
Discussion started by: Pandee
3 Replies

5. Shell Programming and Scripting

How to find a existing file location and directory location in Solaris box?

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 (1 Reply)
Discussion started by: buzzme
1 Replies

6. Shell Programming and Scripting

Find Set of files

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... (3 Replies)
Discussion started by: Shanks
3 Replies

7. Shell Programming and Scripting

Help on Moving files from one location to another location

Hi, I am new to unix and shell scripting. Please help me in resolving the below issue. In my shell script I have a variable which stores the different files with the path. Now I need to move all the files one by one to another location. ---- 1.... (4 Replies)
Discussion started by: kpagadala
4 Replies

8. Shell Programming and Scripting

Shell Script for Copy files from one location to another location

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. (2 Replies)
Discussion started by: allways4u21
2 Replies

9. Shell Programming and Scripting

Transfer files from one location to another location

Hi, i have to transfer of files of User1 located in Location1 to user2 located in Location2 using shell script. Please suggest me. (1 Reply)
Discussion started by: KiranKumarKarre
1 Replies

10. UNIX for Advanced & Expert Users

copy files from one location to similar location

I need help in forming a script to copy files from one location which has a sub directory structure to another location with similar sub directory structure, say location 1, /home/rick/tmp_files/1-12/00-25/ here 1-12 are the number of sub directories under tmp_files and 00-25 are sub... (1 Reply)
Discussion started by: pharos467
1 Replies
Login or Register to Ask a Question