I am attempting to do a comparison before I append conditions to a profile.d file
grep -F 'TMOUT' /etc/profile.d/sh.local shows me exactly what I expect however the test is always showing true. In all of these examples I've already appended the information I want to sh.local but I don't want to do it again if it is present.
[ ! `grep -Fq 'TMOUT' /etc/profile.d/sh.local` ] && echo $? 0 [ ! `grep -Fq 'NOT_PRESENT' /etc/profile.d/sh.local` ] && echo $? 0
Although this is for an .ebextension command the tests are failing before I even try to deploy, I imagine the final result should look like this but I'm obviously wrong about something. I've tried using $(grep) vs `grep`. Also ==1 vs !
01_hard_5.4.5_shell_timeout: test: "[ $(grep -Fxq 'TMOUT' /etc/profile.d/sh.local) ==1 ]" command: | printf '\nTMOUT=300\nreadonly TMOUT\nexport TMOUT\n' | sudo tee -a /etc/profile.d/sh.local >/dev/null
And for the record this is Amazon Linux 2 and the following commands spit out the following
grep -F 'TMOUT' /etc/profile.d/sh.local TMOUT=300 readonly TMOUT export TMOUT grep -F 'NOT_PRESENT' /etc/profile.d/sh.local