Untitled

 avatar
unknown
plain_text
a year ago
373 B
2
Indexable
#!/bin/bash

# Specify the directory path and prefix
directory_path="/path/to/your/directory"
prefix="your_prefix"

# Use ls and grep to filter files by prefix
matching_files=$(ls -1 "$directory_path" | grep "^$prefix")

# Use sort to sort the matching files by suffix
sorted_files=$(echo "$matching_files" | sort -t_ -k2,2n)

# Print the sorted files
echo "$sorted_files"
Leave a Comment