Fileformat checking

Hi All,

Seeking for your assistance to output the file if there's a wrong format in the file name.

ex.
i have a file name
Correct Format: ar1010001a16.zip
Invalid Format: ar1a1001416.zip

what i did was 
ls ar[0-9][0-9][0-9][0-9][0-9][0-9][0-9][a-z][0-9][0-9][.][z][p] - i get the correct format. however my problem is how can i output the filename that has incorrect format.

Please advise,

Thanks,

A quick and dirty way to get what you want would be:

ls ar[0-9][0-9][0-9][0-9][0-9][0-9][0-9][a-z][0-9][0-9].zip > OK
ls *.zip | grep -v -F -f OK
rm -f OK
1 Like

Unfortunately you don't mention your system's info like the shell you use. In a recent bash offering "extended pattern matching", you could try

shopt -s extglob
ls ar!([0-9][0-9][0-9][0-9][0-9][0-9][0-9][a-z][0-9][0-9]).zip
ar1a1001416.zip
1 Like

I'm using shell Sir Rudic.

Saying you're "using shell" is like writing 'car' under 'model' when signing in your vehicle for repair. It's not exactly wrong, but not helpful either.

Using what shell? bash, dash, ash, ksh, ksh88, zsh, crusty old unchanged-since-1977 plain vanilla sh, csh(god forbid), or other?