Home > OS >  How do I make an bash script based on this?
How do I make an bash script based on this?

Time:02-02

When I run this command it shows all the inactive users in this format user:INACTIVE. I only want to print out the users with greater than 30 days or empty "".

grep -E ^[^:] :[^\!*] /etc/shadow | cut -d: -f1,7

This is my attempt however it only outputs root.

#!/bin/bash
if users = ( $(awk -F '$7 > 30 || $7 == "" {print $1" " $7;rc=1}END{exit !rc}' /etc/shadow) )
then
   echo $users
fi

CodePudding user response:

Why do you not just put your initial command into a bash file?

It's works on wsl Debian. What system are you using?

CodePudding user response:

Try:

#!/bin/bash

awk -F: '$2 != "*" && ($7 0 > 30 || $7 == "") {print $1 ":" $7}' /etc/shadow
  •  Tags:  
  • Related