我需要搜索多个日志文件(过去 24 小时内生成的所有文件,都保存在同一目录中)以找到最后一次出现的字符串。这是我写的命令:
find . -mtime 1 | grep fileprefix | xargs grep 'search string' | tail -1
Run Code Online (Sandbox Code Playgroud)
但这仅返回一个文件的最后一行。关于如何调整它以获得所有线条的任何建议?
我正在执行下面的脚本,但出现错误“ line 14: last-tag=TSTA-6: command not found
”,即在我尝试将命令输出存储在变量中时(TSTA-6 是命令的输出)。任何想法我哪里出错了?
#!/bin/bash
echo "This script will remote trigger tagging job. Kindly provide Inputs"
release=-1
if [ -z "$1" ];then
echo "Enter release number [In 3 digit format i.e. 20.0.0] "
read release
else
release="$1";
fi
last-tag=$(svn ls -v https://abc.com/tags | sort -k1 | tail -1 | tr -s ' ' | cut -d' ' -f7 | cut -d'/' -f1)
echo "release is: $last-tag "
Run Code Online (Sandbox Code Playgroud)