My issue is as follows:
This is the content of variable res:
% echo $res
large__noninteractive($|[[:blank:]])" | grep -E "(^|[[:blank:]])RAM.3000000($|[[:blank:]])" | grep -E "(^|[[:blank:]])CORES.1
And when I do as follows it gives me results (everything after grep -E "(^|[[:blank:]])
and before ($|[[:blank:]])
" is the identical to the content of $res) :
cat queuedjobs | grep -E "(^|[[:blank:]])large__noninteractive($|[[:blank:]])" | grep -E "(^|[[:blank:]])RAM.3000000($|[[:blank:]])" | grep -E "(^|[[:blank:]])CORES.1($|[[:blank:]])"
but when I do:
cat queuedjobs | grep -E "(^|[[:blank:]])$res($|[[:blank:]])"
There are no results even though it is supposedly identical. I would appreciate any ideas for solving this issue.
- I'm testing it in the command line but it will enter into a script.
- I made the res as follows:
resource="large__noninteractive RAM.2500000 CORES.4"` res=`echo $resource | sed "s/${queue}//g" | awk '{$1=$1};1' | sed 's/ /($|[[:blank:]])" \| grep -E "(^|[[:blank:]])/g'`
|
in a variable like that. Also, in your case I'd suggest using an array of patterns and something like https://unix.stackexchange.com/a/326270/70524 instead. – muru Oct 19 '20 at 09:06cat queuedjobs | grep -E "(^|[[:blank:]])$res($|[[:blank:]])"
a part of a Bash script or typed in the terminal? – Alexander Mashin Oct 19 '20 at 09:06grep
commands actually part of the value$res
? – Kusalananda Oct 19 '20 at 09:07