简体   繁体   中英

Shell script : sed command is ignoring INFO lines given main 2>&1

main 2>&1 is giving INFO, ERROR and Running status lines. But when I use sed on it, it is giving INFO and Running status lines along with ERROR lines but they are not in the order where they have to.

Jumbled status are at the end after job executed succefully .

main 2>&1 | sed "/ERROR.*[0-9]\{1\}.[0-9]\{1\}.[0-9]\{1\}.[0-9]\{1\}-[0-9]\{3\}.*20[0-9]\{2\}-[0-9]\{2\}-[0-9]\{2\}_[0-9]\{2\}-[0-9]\{2\}-[0-9]\{2\}.*(stderr)/ s/ERROR/NOTE/" | tee -a $log_file

These are the lines which are missing after I use sed command: 在此处输入图片说明

如果您在sed中附加/\\(Running\\|INFO\\ERROR... ,如下所示,这还可以打印Running和info以及ERROR行

main 2>&1 | sed "/\(Running\|INFO\|ERROR.*[0-9]\{1\}.[0-9]\{1\}.[0-9]\{1\}.[0-9]\{1\}-[0-9]\{3\}.*20[0-9]\{2\}-[0-9]\{2\}-[0-9]\{2\}_[0-9]\{2\}-[0-9]\{2\}-[0-9]\{2\}.*(stderr)\)/ s/ERROR/NOTE/" | tee -a $log_file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM