79380629

Date: 2025-01-23 10:22:24
Score: 3.5
Natty:
Report link

I see I can achieve this using stat command as below and then trying to match with date parameter that can be passed to the script,

file_pattern="file.subfile.P*.lastfile"

files=$(ls $file_pattern 2>/dev/null)

for file in $files; do last_modified_date=$(stat --format='%y' "$file" | cut -d' ' -f1)

if [ "$last_modified_date" == "$input_date" ]; then echo "Processing file: $file (Last Modified: $last_modified_date)"
else echo "Skipping file: $file (Last Modified: $last_modified_date)" fi done

Is this better or trying to add suffix date in source file & then trying to capture is better?

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Ends in question mark (2):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Ashwanth arul