bash - shell中IF语句中两个变量之间的正斜杠是什么意思?
问题描述
我想了解这里两个变量之间的正斜杠是做什么的?
“${lsof_line/$c2}”
下面是上下文。(c2_iocs 是一个文本文件)
lsof_output=$(lsof -i)
for lsof_line in ${lsof_output}; do
for c2 in "${c2_iocs[@]}"; do
# echo "$lsof_line - $c2"
if [ "${lsof_line/$c2}" != "$lsof_line" ]; then
log warning "[!] C2 server found in lsof output SERVER: $c2 LSOF_LINE: $lsof_line"
fi
done
done
解决方案
这是一个字符串替换操作。当没有提供替换文本时,/
以下模式是可选的。${lsof_line/$c2}
相当于, 并且都删除了from${lsof_line/$c2/}
中包含的字符串。$c2
$lsof_line
推荐阅读
- json - JSON 对象有值,但它们是空的
- php - 如何在电报机器人中使用回调数据
- android - 下载新文件后尝试显示系统通知时应用程序崩溃
- android - Activity 已泄露窗口 com.android.internal.policy.impl.PhoneWindow$DecorView{3dd12f3a VE.... R......D 0,0-1026,348}
- linux - How to copy multiple pages from VI inside tmux session
- r - R future_lapply 与 SLURM 仅按顺序运行
- sql - 在 PostgreSQL 中用规则替换插入
- amazon-web-services - 在 aws 上记录用户操作
- .net - 如何解决?.Net Core App 上的 Identity Server 4、500 内部服务器错误
- python-3.x - 检查不返回函数的数据类型