1

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.

1
  • Have a look at the following link regarding basename
    – kingmilo
    Mar 21, 2013 at 19:18

1 Answer 1

1

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .