I am trying to grep
with all elements of array but it is breaking because of spaces.
Below is the value of my array:
server:/home/a-hkat # echo "${hitesharray2[@]}"
ida0481.abc.xyz.net:/J 'ida0481.abc.xyz.net [/J]'
server:/home/a-hkat # declare -p hitesharray2
declare -a hitesharray2='([0]="ida0481.abt.xyz.net:/J" [1]="'\''ida0481.abc.xyz.net [/J]'\''")'
Below is the error:
server:/home/a-hkat # omnidb -winfs | grep "${hitesharray2[@]}"
grep: 'ida0481.abc.xyz.net [/J]': No such file or directory
Desired result should be as below but using array:
server:/home/a-hkataria # omnidb -winfs | grep ida0481.abc.xyz.net:/J
ida0481.abc.xyz.net:/J 'ida0481.abc.xyz.net [/J]'
In short, I want to grep the below lines using an array or some other alternative.
server:/home/a-hkat # echo "${hitesharray2[@]}"
amerfs0039.abc.xyz.net:/F 'amerfs0039.abc.xyz.net [/F]'
server:/home/a-hkat # omnidb -winfs | grep amerfs0039.abc.xyz.net:/F
amerfs0039.abc.xyz.net:/F 'amerfs0039.abc.xyz.net [/F]' WinFS