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.

0

1 Answer 1

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
2
  • Thanks for the working solution. Any one-liners possible?
    – Prradep
    Apr 7, 2017 at 9:35
  • 1
    added one-liner
    – Kamaraj
    Apr 10, 2017 at 7:35

Not the answer you're looking for? Browse other questions tagged .