To delete the first letter of each directory name in a shell script

Question: Question:

How can I change the directory names in a batch using a shell script in a UNIX environment as shown below?

Change before:

  • a12456
  • b12459
  • e12461
  • u12467

After change:

  • 12456
  • 12459
  • 12461
  • 12467

Answer: Answer:

If you like bash,

$ for f in *; do mv "$f" "${f:1}"; done

is. Please note that all files other than those starting with . In the current directory are targeted because it is for f in * .

Scroll to Top