0

I have to remove _ which is as prefix for a file. I used:

for i in _*.txt; do mv ${i} ${i/#_/''}; done

but it does not change the names of the files which has space in between as _abc xyz-abc.txt

I want _ as prefix to be removed from all the files in a directory irrespective of space.

cuonglm
  • 153,898
shruti
  • 1

1 Answers1

2

Try:

for i in ./_*.txt; do
  mv "$i" "${i#_}"
done

It assumed that you ran a POSIX shell - /usr/xpg4/bin/sh with Solaris 10 and earlier.

cuonglm
  • 153,898