Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
    
Great question, but scripting q's really belong on stack overflow. –  Amanda Jan 28 '12 at 1:11
    
@Amanda you mean superuser.com :) –  medigeek Jan 28 '12 at 23:33
    
@medigeek, aah. right. –  Amanda Jan 29 '12 at 1:56

3 Answers 3

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/^\._//' ._*
share|improve this answer

using rename:

rename -v 's/\._//' ._*

example:

$ touch ._aaa
$ rename -v 's/\._//' ._*
._aaa renamed as aaa
share|improve this answer

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"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.