0

First, here's the script I'm talking about: https://github.com/Greduan/dotfiles/blob/master/scripts/symlinks.sh

Check line 20. It has the following content

dest = "$HOME/.`basename \"${source%.*}\"`"

Since I took this from another script, I have no idea what it actually does. I'm guessing what it does is if the source file is named vimrc.vim.symlink it'll output .vimrc.vim, correct?

If not correct, could you please explain what it does?

And could you please help me figure out how to make it so that if the file is vimrc.vim.symlink, how can I make it so that I can get .vimrc?

Please check the script so that you can understand what I'm talking about. :)

greduan
  • 4,770
  • 6
  • 45
  • 73

1 Answers1

1

First of all, your analysis is correct. ${source%.*} removes the .* suffix from source. The rest, $HOME/.$(basename \"...\") takes the basename of source, which removes all path from it, leaving only the file name and is placed after $(HOME)/..

If you want to remove everything after (and including) the first dot, you can use ${source%%.*} (with %% instead of %). This answer gives you examples.

Community
  • 1
  • 1
Shahbaz
  • 46,337
  • 19
  • 116
  • 182