Search code examples
unixdotfilesln

Symlink and hide dotfiles


How could I rename a bunch of dotfiles and add the leading dot in the same command? I see people writing:

ln -s vimrc .vimrc
ln -s gitconfig .gitconfig

But I would like something like this:

ln -s {vimrc,gitconfig} ~/.$1


Solution

  • Using for loop:

    for f in vimrc gitconfig; do ln -s  $f .$f ; done
    

    If you have the filename list in a file:

    for f in `cat filename_list.txt`; do mv $f .$f ; done