bash - sed 特定的精确数学
问题描述
我有一个 file.txt,其中包含例如
/tmp/blabla/
/tmp
/blabla/tmp/muzi
/muzi/puzi/bla/bla/tmp
我需要编写一个接受用户输入的函数,然后继续删除文件中的 EXACT 匹配项
function Remove_Project_Dir () {
[[ $(grep -w $1 $version_db_file | wc -l) != 0 ]] && sed -i '/"$1"/d' $version_db_file || echo "Directory supplied doesnt exist in version db"
}
#Should only remove /tmp if there's such thing
Remove_Project_Dir /tmp
我在使用包含“/”的 sedding 字符串时遇到问题,也找不到如何只删除完全匹配的内容。任何帮助将不胜感激
解决方案
推荐阅读
- arrays - 将 for 循环的输出保存在 Bash 的数组中
- stanford-nlp - NER 写完了自定义 NERin stanford NLP
- python - 如何制作多个文件 Python Bot
- python - Django:使用 value_list 查找 id
- python - 加权字符串的组合:用 sum(integers) = m 计算整数组合的数量
- python - 动态手势识别和 Kinect 与 Python?
- linux - 如何提取 ASA 916.bin 以在 GNS3 中使用?
- json - 过滤 JSON 数组以显示多个或单个键值
- excel - 不保存模板
- .net - 如何使用合适的 AL 运行时版本?