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

前端 未结 6 806
清酒与你
清酒与你 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:49

    realpath resolves given path. Among other things it also removes trailing slashes. Use -s to prevent following simlinks

    DIR=/tmp/a///
    echo $(realpath -s $DIR)
    # output: /tmp/a
    

提交回复
热议问题