从变量的末尾删除斜杠 [英] Remove slash from the end of a variable
本文介绍了从变量的末尾删除斜杠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在bash自动完成做出/在目录结尾我怎么可以剥夺了这一点?
感谢您的提示。
#!/ bin / sh的目标= $ 1功能的备份(){
日期=`日期+%Y%M%D_%H%M%S`
PWD =`pwd`
PATH = $ PWD / $的目标
焦油CZF /tmp/$date$target.tar.gz $ PATH
}备用
解决方案
使用
目标= $ {1%/}
一个参考。
the bash auto completion make a / at the end of a directory how i can strip this out?
Thanks for hints.
#!/bin/sh
target=$1
function backup(){
date=`date "+%y%m%d_%H%M%S"`
PWD=`pwd`
path=$PWD/$target
tar czf /tmp/$date$target.tar.gz $path
}
backup
解决方案
Use
target=${1%/}
A reference.
这篇关于从变量的末尾删除斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文