简体   繁体   中英

Bash - Add symlinks in multiple directories

For my magento installation I have to add some symlinks in language directories.

I have the following language directories: EN, NL, DE, FR and IT.

These are the commands that have to be executed.

ln -s /path/to/magento/installation/app /path/to/magento/installation/en/app
ln -s /path/to/magento/installation/skin /path/to/magento/installation/en/skin
ln -s /path/to/magento/installation/var /path/to/magento/installation/en/var
ln -s /path/to/magento/installation/js /path/to/magento/installation/en/js
ln -s /path/to/magento/installation/media /path/to/magento/installation/en/media
ln -s /path/to/magento/installation/app /path/to/magento/installation/nl/app
ln -s /path/to/magento/installation/skin /path/to/magento/installation/nl/skin
ln -s /path/to/magento/installation/var /path/to/magento/installation/nl/var
ln -s /path/to/magento/installation/js /path/to/magento/installation/nl/js
ln -s /path/to/magento/installation/media /path/to/magento/installation/nl/media
ln -s /path/to/magento/installation/app /path/to/magento/installation/ru/app
ln -s /path/to/magento/installation/skin /path/to/magento/installation/ru/skin
ln -s /path/to/magento/installation/var /path/to/magento/installation/ru/var
ln -s /path/to/magento/installation/js /path/to/magento/installation/ru/js
ln -s /path/to/magento/installation/media /path/to/magento/installation/ru/media
ln -s /path/to/magento/installation/app /path/to/magento/installation/fr/app
ln -s /path/to/magento/installation/skin /path/to/magento/installation/fr/skin
ln -s /path/to/magento/installation/var /path/to/magento/installation/fr/var
ln -s /path/to/magento/installation/js /path/to/magento/installation/fr/js
ln -s /path/to/magento/installation/media /path/to/magento/installation/fr/media
ln -s /path/to/magento/installation/app /path/to/magento/installation/de/app
ln -s /path/to/magento/installation/skin /path/to/magento/installation/de/skin
ln -s /path/to/magento/installation/var /path/to/magento/installation/de/var
ln -s /path/to/magento/installation/js /path/to/magento/installation/de/js
ln -s /path/to/magento/installation/media /path/to/magento/installation/de/media
ln -s /path/to/magento/installation/app /path/to/magento/installation/it/app
ln -s /path/to/magento/installation/skin /path/to/magento/installation/it/skin
ln -s /path/to/magento/installation/var /path/to/magento/installation/it/var
ln -s /path/to/magento/installation/js /path/to/magento/installation/it/js
ln -s /path/to/magento/installation/media /path/to/magento/installation/it/media

Is there a way to make this less redudant?

Why not try to use bash script

#!/bin/bash
FOLDERS=(app skin var js media);
LOCALES=(en nl de fr it);
for i in FOLDERS; do
    for j in LOCALES; do
        ln -s /path/to/magento/installation/${FOLDERS[i]} /path/to/magento/installation/${LOCALES[j]}/${FOLDERS[i]}
    done
done

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM