Hello
Thanks everyone for the help earlier, what I would like to learn now is how can I achieve the following :
array1 = (1234567,7665456,998889,000909)
array2 = (1234567,5581445,998889,000909)
Result
5581445 doesn't exist on array1
Thank you
Hello
Thanks everyone for the help earlier, what I would like to learn now is how can I achieve the following :
array1 = (1234567,7665456,998889,000909)
array2 = (1234567,5581445,998889,000909)
Result
5581445 doesn't exist on array1
Thank you
Please show us what you have done so far.
You should have the logic and ask for help on which commands to use.
Usng bash:
array1=(1234567 7665456 998889 000909)
array2=(1234567 5581445 998889 000909)
grep -v -f <(printf "%s\n" "${array1[@]}") <(printf "%s\n" "${array2[@]}")
Ran above code using bash and received the following error:
grep: /dev/fd/62: No such file or directory
The following code works:
array1=(1234567 7665456 998889 000909)
array2=(1234567 5581445 998889 000909)
printf "%s\n" "${array2[@]}" | grep -v "$(printf "%s\n" "${array1[@]}")"
It worked for me though!
root@bt> bash --version
GNU bash, version 4.1.5(1)-release (i486-pc-linux-gnu)
root@bt> array1=(1234567 7665456 998889 000909)
root@bt> array2=(1234567 5581445 998889 000909)
root@bt> grep -v -f <(printf "%s\n" "${array1[@]}") <(printf "%s\n" "${array2[@]}")
5581445
--ahamed
I used:
GNU bash, version 3.2.0(1)-release (x86_64-unknown-linux-gnu)
As much as possible, if one solution can be given in a more universal usage, then we must provide it.
Otherwise, for the same requirement, there will be several possible solutions, based on which OP (linux, unix), shell, shell version, etc.
Let's be generic as much as we can.