I have several files' names starting with "._". I'd like to remove the point and underscore in a script. Howto do this?
Thank you very much in advance.
I have several files' names starting with "._". I'd like to remove the point and underscore in a script. Howto do this?
Thank you very much in advance.
This is a dry-run (simulates the command, doesn't execute it):
rename -n 's/^\._//' ._*
If you like the output, execute it:
rename -v 's/^\._//' ._*
using rename
:
rename -v 's/\._//' ._*
example:
$ touch ._aaa
$ rename -v 's/\._//' ._*
._aaa renamed as aaa
Your question can be interpreted in two ways, "renaming" and "get the filename with ._ removed". For rename, see the other questions. For the second possibility, use variable expansion:
name=._file
stripped_name="${name#._}"
# the below will output: ._file becomes file
echo "$name becomes $stripped_name"