提取值并读取为变量

extract value and read as variable

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 of tasks 即'128'和'16' ptile。想在变量

中读取这个值

任务 = 128 ptile = 16

您可以将 grep -Pread 一起使用:

read task ptile < <(grep -oP '.*\K\b\d+(?= Task)|.*ptile=\K\d+' file | tr '\n' ' ')

echo "[$task] - [$ptile]"
[128] - [16]