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 a question which is super simple, but I just can't wrap my head around it. Regarding the following command line:

for foo in *.dist; do cp $foo `basename $foo .dist`; done

I know it takes all files in the current directory which have .dist as an extension, copies them and in the same step removes the .dist extension (I have grapped it from a wiki post regarding the installation of OTRS under Ubuntu Server). I just want to understand WHY it is doing this.

Thank you very much.

share|improve this question
    
Have a look at the following link regarding basename –  kingmilo Mar 21 '13 at 19:18

1 Answer 1

up vote 1 down vote accepted

from man basename

NAME basename - strip directory and suffix from filenames

SYNOPSIS basename NAME [SUFFIX] basename OPTION

DESCRIPTION Print NAME with any leading directory components removed. If speci‐ fied, also remove a trailing SUFFIX.

so, the command basename is doing this

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.