Create a list of missing files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Create a list of missing files
# 1  
Old 11-16-2013
Create a list of missing files

Hello Guys

I have a big list of files in one directory. And Some are missing .

Example
ls -l
Code:
2191off-r0.sps
2193off-r0.sps
2194off-r0.sps
2197off-r0.sps
2198off-r0.sps
2200off-r0.sps

I would like to create a file with the list only missing files. Or if is possible to create in
the same directory empty files

example
I should get the following files in the same directory.. Empty files. Or a List with the missing files.

Code:
2192off-r0.sps
2195off-r0.sps
2196off-r0.sps
2199off-r0.sps

Thanks a lot for your cooperation. Smilie
# 2  
Old 11-16-2013
Try
Code:
for i in {2191..2200}off-r0.sps; do [ -f $i ] || echo $i; done

This is for the list; replace echo by touch (or redirection >) to create the files.
This User Gave Thanks to RudiC For This Post:
# 3  
Old 11-16-2013
If you don't care about the modification times on those files, then this will create missing files as empty files:
Code:
for i in {2191..2200}; do touch "${i}off-r0.sps"; done

This User Gave Thanks to bartus11 For This Post:
# 4  
Old 11-16-2013
Alternative approach:
Code:
ls | awk '!/\.sps$/{next}{n=$1+0} p!=""{while(++p<n){sub(/^[0-9]*/,p); print}} {p=n}'


Last edited by Scrutinizer; 11-16-2013 at 04:44 PM..
This User Gave Thanks to Scrutinizer For This Post:
# 5  
Old 11-16-2013
Thanks a lot to all Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Create a list of files from alias by script

Actually I have many pictures with diferent name and size around 2000, I need generate a copy of them from one list of alias. The structure of the list is something like this: alias_list.txt <01>randomname.png<02> Randomname.png RandoMname.png RandOmname.png RandomnamE.png... (6 Replies)
Discussion started by: Tapiocapioca
6 Replies

2. Shell Programming and Scripting

How to find list of missing files based on the file format?

Hi All, In the file names we have dates. Based on the file format given by the user, if any file is not existed for a particular date with in a given interval we should consider that file is missing. I have the below files in the directory /bin/daily/voda_files. ... (9 Replies)
Discussion started by: nalu
9 Replies

3. Shell Programming and Scripting

Find list of files missing read & execute permission

Hi, I'm writing a post-upgrade script and I want to find which files don't have read and execute to everyone. I can run a find . ! -perm, but then I have to use a list of the possible permissions (777,775, 755 etc). Is there a more elegant solution? Thanks (2 Replies)
Discussion started by: Catullus
2 Replies

4. Shell Programming and Scripting

Scan directories and create a list of files

Gents, Please can you help. I want to create a list which contends the complete patch of the location of some directories with the size of each file. need to select only .txt file In this case I am try to find the subdirectories tp1 and tp2 and create the output list. jd175-1 tp1... (3 Replies)
Discussion started by: jiam912
3 Replies

5. Shell Programming and Scripting

Create empty files from a list on file

Hello Guys. Please I would like to create empty files from a list In file1 will be the followin values, so i will like to create for each name a empty file. file1 2191off-r0.sps 2192off-r0.sps 2193off-r0.sps 2194off-r0.sps 2195off-r0.sps So I need to get 5 empty files. Thanks for... (7 Replies)
Discussion started by: jiam912
7 Replies

6. Solaris

Command to list all header files used to create an executable

All, I would like to know if there is a command which will list all the header files which were used while creating the executable. (1 Reply)
Discussion started by: helper
1 Replies

7. Shell Programming and Scripting

Create files from a list and then populate them

I have a list of filenames that I want created - they must be created via a certain naming convention due to the software I'm using. Once they are created I have another file that will be used to populate them with data. So far this is what I have: #For each line in text file "foo_txt" create... (2 Replies)
Discussion started by: MaindotC
2 Replies

8. Shell Programming and Scripting

Find missing files from a list

counter=0; while read line; do ] && let counter=counter+1; done < input_file.txt echo $counter The above code is reading a file line by line and checking whether the filenames mentioned in the file exist or not . At present the o/p is value of counter I want to echo out the name of... (5 Replies)
Discussion started by: ultimatix
5 Replies

9. Shell Programming and Scripting

How to create multiple list of files in a directory ?

Hi, i have say 100 files in a directory. file1.log file2.log file3.log file4.log file5.log file6.log ... ... ... file99.log file100.log ========= I need to create another file which contains the list of al these log files. each file should contain only 10 log file names. it shud... (4 Replies)
Discussion started by: robinbannis
4 Replies

10. UNIX for Dummies Questions & Answers

Create a list of files that were modified after a given date.

Hello Mates! I'm kinda new to unix and need to a solve a problem. Input: date Situation: With the given date I need to find a list of all such files starting from a given path that were modified after the given date. I experimented with the "find" with "-newer" but did not quite get it... (4 Replies)
Discussion started by: rkka
4 Replies
Login or Register to Ask a Question