Below is the code I am trying:
{
echo "Enter dirname and hit Return"
read input1
echo "Enter a pattern to be searched for in the current directory"
read input2
find /*/${input1}/*/logs/*/*/*/* -name '*.gz' -exec sh -c 'gzip -cd "$0" | grep -- "${input2}"' {} \;
}
while the input1 matches but the input2 doesnt seem to match and I am getting all the outputs of input1 without getting input2 matched with it.
purpose is to read all the .gz files and get the keyword input2 match.
export input2
for it to be available tosh
. Also add-r
toread
for it not to treat backslash specially. AddIFS=
forread
not to strip leading and trailing blanks. (and quote$input1
)