0

I need assign the Output of comm Command to variable. I use comm to campare two list of values.

These two lists are defined as:

DATA_REF_DATA_OPIT_SIP='PCSCF4A
PCSCF4B
PCSCF5A
PCSCF5B'
DataExist='PCSCF4B
PCSCF5A
PCSCF5B'

And when i do

comm -23 <(sort <<<"$DATA_REF_DATA_OPIT_SIP") <(sort <<<"$DataExist")

Output :

PCSCF4A

I want to assign the output of comm to a Variable. So i did :

res=$(comm -23 <(sort <<<"$DATA_REF_DATA_OPIT_SIP") <(sort <<<"$DataExist"));
echo $res

I get empty output.

instead of :

echo $res
PCSCF4A

Please Help. Thanks you.

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441
  • Yeah it's DataExist and not DataH323.but the output still null –  Nov 28 '17 at 17:50
  • 1
    Provide something I can copy-and-paste to get that null output -- when I run the code at https://ideone.com/A9vlJx, I get the desired output (and so does ideone's online shell, now that it actually ran). – Charles Duffy Nov 28 '17 at 17:50
  • I think, it's problem of version that i have it –  Nov 28 '17 at 17:59
  • I doubt very much that this is version-specific. If you're using the same shell for both the line that works and the line that doesn't, then it's already known to support all the necessary syntax. – Charles Duffy Nov 28 '17 at 18:00
  • Anyhow, can you reproduce the problem when you copy-and-paste the code from my ideone link above (and thus are using that link's variable definitions, exact and unmodified)? – Charles Duffy Nov 28 '17 at 18:01
  • i get like this output PCSCF4A PCSCF4B PCSCF5A PCSCF5B PCSCF4B PCSCF5A PCSCF5B when i test the same example what you put in https://ideone.com/A9vlJx –  Nov 28 '17 at 18:06
  • Are you sure you copied-and-pasted *exactly* from the webpage, without retyping anything? Note that ideone has its own bash interpreter, and it shows the output as `PCSCF4A` from when it ran the code itself. – Charles Duffy Nov 28 '17 at 18:08

0 Answers0