0

I have a process creating the following files, which share a similar pattern.

file_1.txt
file_2.txt
.
.
.
file_1000.txt
.
.
.
file_1901.txt
file_1902.txt

But, there are only 1890 files in the folder. I would like to know if there is a way to identify the missing files from the list of files sharing a pattern.

Prradep
  • 203

1 Answers1

2
#!/bin/bash

for i in {1..2000}
do
    file_name="file_${i}.txt"
    if [ ! -f ${file_name} ]
    then
        echo "${file_name} not exists.."
    fi
done

for i in {1..2000};do file_name="file_${i}.txt"; [ -f ${file_name} ] || echo "${file_name} not exists"; done
Kamaraj
  • 4,365