begincoding123 begincoding123 - 1 month ago 14
Bash Question

List files with extention matching conditions

I am trying to list all .mp4 files that start with D and the length of filename should be minimum of 5 in a single command. I dont know how to add the length requirement into the command. This is what i have so far:

ls [D]* | *.mp4

Answer

This will do it:

ls D????*.mp4

? matches any single character; * matches 0 or more of any character. D???? means "a string starting with D and 4 more characters". This encodes your length requirement.