Writing a single line command that interprets conditional output from pdbedit

Hamking

I would like to run a command on a single line that will tell me if the flag is set for a user's password to be changed on next login. This command will interpret the output and return a true/false.

If the PWMC flag is NOT set, I get a date stamp like this:

pdbedit -L -v <USER.NAME> | grep "Password must change:"
> Password must change: Wed, 30 Oct 2013 08:54:01 CDT

If the PWMC flag IS set, the command returns this:

pdbedit -L -v <USER.NAME> | grep "Password must change:"
> Password must change: 0

So how would I compose a command that can be run on a single line that will tell me through a true/false statement that the PWMC flag is set for a given user?

Thanks!

tehsven

Taking "return a true/false" to mean echo the string "true" or "false", then this one-liner should do it:

pdbedit -L -v "$USER_NAME" | if grep -Eq 'Password must change:\ +0'; then echo "true"; else echo "false"; fi

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Extract single line from command output in terminal

BATCH - How to get only a single line from a multi-line command output

Multiple conditional output from single input

Formatting command output that is a long single line

Mathematics on output from command line

writing the output from split command to a separate directory

Continuously writing output from Linux command to file

Extracting columns from multiple files into a single output file from the command line

How can you pass a multi-line output from one command as n arguments to a single command, not n commands with a single argument?

Windows: Writing & to a file from command line

writing to serial port from linux command line

Output data from subprocess command line by line

Writing only first line of the command output in Windows cmd to a file

Merge column from command output into a single row

Create file from output on single line

Start single Serenity scenario from command line

Writing command output to file

Disable and enable audio output from the command line

Prepending a timestamp to each line of output from a command

Command line: Extract substring from output

Parsing a string to an array output from command line

Get specific line from command output in awk

Change sound output from command line

OpenNLP POSTagger output from command line

Hide default command line output from 'at'

append text to an output from command line

Grabbing a number from string output on command line

Get middle line from the output of a command

Writing to command line arguments