The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #6 (permalink)  
Old 04-30-2007
reborg's Avatar
reborg reborg is offline Forum Staff  
Administrator
  
 

Join Date: Mar 2005
Location: Ireland
Posts: 4,246
Quote:
Originally Posted by ghostdog74
Code:
awk -F ":" 'BEGIN{OFS = ":"} /youruser/{$2="*LK*"}{ print}' /etc/passwd

please use at own risk.
Actually you should not use this code, a partial match will result in locking the wrong user.

eg users: user2 and user23 projectuser234 , using user2 will lock all three.


Code:
awk  'BEGIN{IFS = OFS = ":"} $1 == "youruser" { $2 = "*LK*" } { print }' /etc/passwd