Thu Feb 19 10:42:50: Submitted from host <iitmlogin5-ib0>, CWD <$HOME/Bipin/JAS_Data/Big_Domain/128np_IC/Normal_queue>, Output File <file.stdout.159375>, Error File <file.stderr.159375>, Exclusive Execution, 128 Task(s), Requested Resources <span[ptile=16]>; RUNLIMIT
从上面给出的行,我想提取任务的值No,即&#39; 128&#39;和&#39; 16&#39; ptile。想要在变量中读取这个值
任务= 128 ptile = 16
答案 0 :(得分:2)
您可以将grep -P
与read
:
read task ptile < <(grep -oP '.*\K\b\d+(?= Task)|.*ptile=\K\d+' file | tr '\n' ' ')
echo "[$task] - [$ptile]"
[128] - [16]