Thursday, May 9, 2024
 Popular · Latest · Hot · Upcoming
11
rated 0 times [  11] [ 0]  / answers: 1 / hits: 790  / 2 Years ago, sun, december 5, 2021, 4:01:43

I have a script.



I want to get all my regular users from /etc/shadow e.g all users which second term in shadow file begins with $ or !$.



My pattern is



sudo getent shadow | awk -F: '$2 ~ /^$/ || /^!$/ {print $1}'


It doesn't work for now.


More From » bash

 Answers
1

You need to escape the $, as it is a special char for "End of Line" much like ^ is "Beginning of Line".



sudo getent shadow | awk -F: '$2 ~ /^$/ || $2 ~  /^!$/ {print $1}'

[#5106] Sunday, December 5, 2021, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
looweets

Total Points: 52
Total Questions: 114
Total Answers: 111

Location: Turkmenistan
Member since Sat, Apr 16, 2022
2 Years ago
;