Linux: Rename Expression To Remove First Character From a File Name

I‘ve over 1000’s of files starting with _ character as follows:


How do I remove the first character from a file name:


You can use the rename command as described in our previous faq. The syntax is as follows:

rename "s/regex-rule/replace/g" *.files

To remove _ first character and rename all *.txt files, enter:

rename -v "s/^_//g" *.txt

Use the ls command to verify the same:
$ ls -l

Posted by: SXI ADMIN

The author is the creator of SXI LLC and a seasoned sysadmin, DevOps engineer, and a trainer for the Linux operating system/Unix shell scripting. Get the latest tutorials on SysAdmin, Linux/Unix and open source topics via RSS/XML feed or weekly email newsletter.