I am getting all the lines as output. The if condition of the following code is not working.
grep -Ev '^(halt|sync|shutdown)' /etc/passwd | awk -F: '{\
if("$7"!="$(which nologin)") \
{ print $0; } \
}'
I tried with different if conditions:
This is also returning all the values.
if("$1"!="usbmux") \
{ print $1; } \
But this is not returning anything even though there is one usbmux entry in $1.
if("$1"=="usbmux") \
{ print $1; } \
grep
andawk
in a piped command; usually,awk
is capable of doing everything by itself, and using only one program can help prevent a lot of mistakes (I've had my share of experience with that ;) ). – AdminBee Mar 06 '20 at 09:01