Forrest logo
back to the ls tool

ls:ai:38a23

List all pdf files inside directory then, using a for cycle, print on scren each filename in alphabetical order adding "_num" before the extension, where "num" is a 3-digit counter starting from 001
$ ls -1 *.pdf | awk '{ printf "%s_%03d\n", substr($0, 0, length($0)-4), NR }' | sort
try on your machine

Lists all pdf files inside directory and prints each filename in alphabetical order with a 3-digit counter

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.

Questions that are answered by this command:

  • List all pdf files inside directory then, using a for cycle, print on scren each filename in alphabetical order adding "_num" before the extension, where "num" is a 3-digit counter starting from 001?
back to the ls tool