Skip to main content
deleted 1 character in body
Source Link
Kusalananda
  • 355.7k
  • 42
  • 735
  • 1.1k
ls *{369..422}*.avi >/dev/null

This will first generate patterns like

*369*.avi
*370*.avi
*371*.avi
*372*.avi
*373*.avi
*374*.avi

through the brace expansion, and then ls will be executed with these patterns, which will give you an error message for each pattern that can't be expanded to a name in the current directory.

Alternatively, if you have no files that contain * in their name:

for name in *{369..422}*.avi; do
    case "$name" in 
        *'*'*'*'*) printf '"%s" not matched\n' "$name" ;;
    esac
done

This relies on the fact that the pattern remains unexpanded if it did not match a name in the current directory. This gives you a way of possibly doing something useful for the missing files, without resorting to parsing the error messages of ls.

ls *{369..422}*.avi >/dev/null

This will first generate patterns like

*369*.avi
*370*.avi
*371*.avi
*372*.avi
*373*.avi
*374*.avi

through the brace expansion, and then ls will be executed with these patterns, which will give you an error message for each pattern that can't be expanded.

Alternatively, if you have no files that contain * in their name:

for name in *{369..422}*.avi; do
    case "$name" in 
        *'*'*) printf '"%s" not matched\n' "$name" ;;
    esac
done

This relies on the fact that the pattern remains unexpanded if it did not match a name in the current directory.

ls *{369..422}*.avi >/dev/null

This will first generate patterns like

*369*.avi
*370*.avi
*371*.avi
*372*.avi
*373*.avi
*374*.avi

through the brace expansion, and then ls will be executed with these patterns, which will give you an error message for each pattern that can't be expanded to a name in the current directory.

Alternatively, if you have no files that contain * in their name:

for name in *{369..422}*.avi; do
    case "$name" in 
        '*'*) printf '"%s" not matched\n' "$name" ;;
    esac
done

This relies on the fact that the pattern remains unexpanded if it did not match a name in the current directory. This gives you a way of possibly doing something useful for the missing files, without resorting to parsing the error messages of ls.

added 93 characters in body
Source Link
Kusalananda
  • 355.7k
  • 42
  • 735
  • 1.1k
ls *{369..422}*.avi >/dev/null

This will first generate patterns like

*369*.avi
*370*.avi
*371*.avi
*372*.avi
*373*.avi
*374*.avi

through the brace expansion, and then ls will be executed with these patterns, which will give you an error message for each pattern that can't be expanded.

Alternatively, if you have no files that contain * in their name:

for name in *{369..422}*.avi; do
    case "$name" in 
        *'*'*) printf '"%s" not matched\n' "$name" ;;
    esac
done

This relies on the fact that the pattern remains unexpanded if it did not match a name in the current directory.

ls *{369..422}*.avi

This will first generate patterns like

*369*.avi
*370*.avi
*371*.avi
*372*.avi
*373*.avi
*374*.avi

through the brace expansion, and then ls will be executed with these patterns.

ls *{369..422}*.avi >/dev/null

This will first generate patterns like

*369*.avi
*370*.avi
*371*.avi
*372*.avi
*373*.avi
*374*.avi

through the brace expansion, and then ls will be executed with these patterns, which will give you an error message for each pattern that can't be expanded.

Alternatively, if you have no files that contain * in their name:

for name in *{369..422}*.avi; do
    case "$name" in 
        *'*'*) printf '"%s" not matched\n' "$name" ;;
    esac
done

This relies on the fact that the pattern remains unexpanded if it did not match a name in the current directory.

Source Link
Kusalananda
  • 355.7k
  • 42
  • 735
  • 1.1k

ls *{369..422}*.avi

This will first generate patterns like

*369*.avi
*370*.avi
*371*.avi
*372*.avi
*373*.avi
*374*.avi

through the brace expansion, and then ls will be executed with these patterns.