Forrest logo
back to the ls tool

ls:ai:e27c4

echo a incrimenting number to the start of files using xargs
$ ls | xargs -I{} sh -c 'i=1; echo "$i {}" >> {}'
try on your machine

Incrementing number will be echoed to the start of each file name in the current directory using xargs. The file names will be listed with ls, piped to xargs, which will execute the shell command to prepend the incrementing number to the file names.

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:

  • echo a incrimenting number to the start of files using xargs?
back to the ls tool