从日志文件读取

时间:2018-06-29 20:39:51

标签: bash

我想选择要搜索的内容来编译bash脚本

./mybash log.txt
root@usa18:/home#muster?: ERROR 
list of all lines containing ERROR
end or search again?: exit
#!/bin/bash
input=$1
while cat $1; read -p "muster?:" | sed -n -e '/$muster/p' >output.txt;
if...(thats not my biggest problem)
fi
done < $1

3 个答案:

答案 0 :(得分:0)

这与您希望做的事情类似吗?

result.13.1<- lmer( measurement ~ (1|part)+(1|operator)+(1|part:operator), data=data.13.1 )

summary(anova(result.13.1))

答案 1 :(得分:0)

这是另一个版本:

#!/bin/bash

# Check the numer of parameters
if (( $# > 0 ))
then
    input="$1"    # Always enclose filename with quotes
else
    echo "USAGE: $0 filename" >&2
    exit 1
fi

while :      # true
do
    read -p "muster?:" muster
    grep  "$muster" "$input"

    read -p "Search again?:" ans
    if [[ $ans == [nN]* ]]
    then
        break
    fi
done

答案 2 :(得分:0)

不好意思解释 我解决了谢谢你的帮助 我的问题是我确实了解与“和”

的区别
#!/bin/bash
input=$1
read -p "what want you search? :" SEARCH
grep -e "{SEARCH}" "$1" > newlog.txt