I am trying to zgrep
multiple strings with the code below, but if I omit one of the parameters it spools a lot of un-matching files. If I enter all the 5 strings it works correctly. How can I zgrep
any number of strings even if its just 3 of 5.
echo "Enter string 1: " read isdn1 echo "Enter string 2: " read isdn2 echo "Enter string 3: " read isdn3 echo "Enter string 4: " read isdn4 echo "Enter string 5: " read isdn5 for host in $(cat host.txt); do ssh "$host" "cd /onip/cdr/output/snapshot/normal/backup && zgrep '$isdn1\|$isdn2\|$isdn3\|$isdn4\|$isdn5' xyz_shot*" done