I have a line like below from a file finalinput.txt
Apr 9, 2021 10:52:35 PM EDT c1d99c1af08ce4ae:-4277b446:178b8700262:-8000-0000000000019a8b 1618023155272 I wrote a small code subtest.sh below
keyinput="c1d99c1af08ce4ae:-4277b446:178b8700262:-8000-0000000000019a8b"
for line in $(cat finalinput.txt)
do
if $line | grep "$keyinput" > /dev/null; then
echo -e "$date $time\n" >> timeoutput.txt
fi
done
output :
line 20: Apr: command not found
./subtest.sh: line 20: 9,: command not found
./subtest.sh: line 20: 2021: command not found
./subtest.sh: line 20: 10:52:35: command not found
./subtest.sh: line 20: PM: command not found
./subtest.sh: line 20: EDT: command not found
./subtest.sh: line 20: c1d99c1af08ce4ae:-4277b446:178b8700262:-8000-0000000000019a8b: command not found
./subtest.sh: line 20: 1618023155272: command not found
./subtest.sh: line 20: ###Update: command not found
./subtest.sh: line 20: Assignment: command not found
./subtest.sh: line 20: Milestone: command not found
./subtest.sh: line 20: Apr: command not found
./subtest.sh: line 20: 9,: command not found
./subtest.sh: line 20: 2021: command not found
./subtest.sh: line 20: 10:52:37: command not found
./subtest.sh: line 20: PM: command not found
./subtest.sh: line 20: EDT: command not found
please help where i am wrong