Awk to get all my regular users in shadowConvey some message to all usersHow can I process multi-line records with awk in a bash script?return value from awkUpstart - unable to read /etc/shadow unless sudoBash: Regular Expressions in substitutionSet expire date for usersGet one element of path string using bashSeparating Commands in a Script File?Substitute cut command inside AWK scriptMake variables show a column with awk
How can I perform a deterministic physics simulation?
Is an "are" omitted in this sentence
Write The Shortest Program to Calculate Height of a Binary Tree
What could prevent players from leaving an island?
A Haskell implementation of Conway's Game of Life, viewable on the console, no external libs
Why is it to say 'paucis post diebus'?
conditional probability of dependent random variables
Based on what criteria do you add/not add icons to labels within a toolbar?
What is it exactly about flying a Flyboard across the English channel that made Zapata's thighs burn?
Meaning of ギャップ in the following sentence
What is the difference between "un plan" and "une carte" (in the context of map)?
Is there a booking app or site that lets you specify your gender for shared dormitories?
State of a Robot
Using Forstner bits instead of hole saws
How do people drown while wearing a life jacket?
Why is Heisenberg shown dead in Negro y Azul?
What is the difference between get_permalink vs get_the_permalink?
If someone else uploads my GPL'd code to Github without my permission, is that a copyright violation?
Difference between "jail" and "prison" in German
Is there a way to say "double + any number" in German?
Is there a command-line tool for converting html files to pdf?
What does "autolyco-sentimental" mean?
Is there a difference between `board[x, y]` and `board[x][y]` in Python?
Why does capacitance not depend on the material of the plates?
Awk to get all my regular users in shadow
Convey some message to all usersHow can I process multi-line records with awk in a bash script?return value from awkUpstart - unable to read /etc/shadow unless sudoBash: Regular Expressions in substitutionSet expire date for usersGet one element of path string using bashSeparating Commands in a Script File?Substitute cut command inside AWK scriptMake variables show a column with awk
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
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.
bash scripts
add a comment |
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.
bash scripts
does it have to be awk? :-)
– Rinzwind
8 hours ago
add a comment |
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.
bash scripts
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.
bash scripts
bash scripts
edited 8 hours ago
Eliah Kagan
87.7k22 gold badges243 silver badges386 bronze badges
87.7k22 gold badges243 silver badges386 bronze badges
asked 8 hours ago
danasodanaso
575 bronze badges
575 bronze badges
does it have to be awk? :-)
– Rinzwind
8 hours ago
add a comment |
does it have to be awk? :-)
– Rinzwind
8 hours ago
does it have to be awk? :-)
– Rinzwind
8 hours ago
does it have to be awk? :-)
– Rinzwind
8 hours ago
add a comment |
2 Answers
2
active
oldest
votes
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'
+1 good catch :)
– Rinzwind
8 hours ago
Thanks, it works. I just need to not include root user
– danaso
8 hours ago
add a comment |
All users with a password set can be listed like this:
getent shadow | egrep '^[^:]*:[*!]:' -v | cut -f1 -d:
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "89"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1163551%2fawk-to-get-all-my-regular-users-in-shadow%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
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'
+1 good catch :)
– Rinzwind
8 hours ago
Thanks, it works. I just need to not include root user
– danaso
8 hours ago
add a comment |
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'
+1 good catch :)
– Rinzwind
8 hours ago
Thanks, it works. I just need to not include root user
– danaso
8 hours ago
add a comment |
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'
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'
edited 8 hours ago
answered 8 hours ago
pLumopLumo
10.4k21 silver badges48 bronze badges
10.4k21 silver badges48 bronze badges
+1 good catch :)
– Rinzwind
8 hours ago
Thanks, it works. I just need to not include root user
– danaso
8 hours ago
add a comment |
+1 good catch :)
– Rinzwind
8 hours ago
Thanks, it works. I just need to not include root user
– danaso
8 hours ago
+1 good catch :)
– Rinzwind
8 hours ago
+1 good catch :)
– Rinzwind
8 hours ago
Thanks, it works. I just need to not include root user
– danaso
8 hours ago
Thanks, it works. I just need to not include root user
– danaso
8 hours ago
add a comment |
All users with a password set can be listed like this:
getent shadow | egrep '^[^:]*:[*!]:' -v | cut -f1 -d:
add a comment |
All users with a password set can be listed like this:
getent shadow | egrep '^[^:]*:[*!]:' -v | cut -f1 -d:
add a comment |
All users with a password set can be listed like this:
getent shadow | egrep '^[^:]*:[*!]:' -v | cut -f1 -d:
All users with a password set can be listed like this:
getent shadow | egrep '^[^:]*:[*!]:' -v | cut -f1 -d:
answered 8 hours ago
RinzwindRinzwind
220k29 gold badges425 silver badges567 bronze badges
220k29 gold badges425 silver badges567 bronze badges
add a comment |
add a comment |
Thanks for contributing an answer to Ask Ubuntu!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1163551%2fawk-to-get-all-my-regular-users-in-shadow%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
does it have to be awk? :-)
– Rinzwind
8 hours ago