What is the simplest way to remove a trailing slash from each parameter?

前端 未结 6 790
清酒与你
清酒与你 2021-01-30 05:55

What is the simplest way to remove a trailing slash from each parameter in the \'$@\' array, so that rsync copies the directories by name?

rsync -a         


        
6条回答
  •  迷失自我
    2021-01-30 06:39

    This works for me: ${VAR%%+(/)}

    As described here http://wiki.bash-hackers.org/syntax/pattern

    May need to set the shell option extglob. I can't see it enabled for me but it still works

提交回复
热议问题