Remove a character from the end of a variable

后端 未结 4 2052
温柔的废话
温柔的废话 2020-12-07 14:17

Bash auto completion appends a / at the end of a directory name. How I can strip this off from a positional parameter?

#!/bin/sh

target=$1

function backup()         


        
4条回答
  •  温柔的废话
    2020-12-07 15:02

    Use target=${1%/}

    See this the parameter substitution of this bash scripting guide for more.

提交回复
热议问题