The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




Thread: awk - print
View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #3 (permalink)  
Old 10-12-2008
c00kie88 c00kie88 is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 63
hi jim,

awk -F: '{print $1 ":" $2 ":" $3 ":" $4}' /etc/shadow > /tmp/shadow.tmp ---> will show all lines within shadow file but not including the one i has edited.
e.g:
name=blah
awk -F: -v user="$name" '$1 == user{print $1 ":" $2 ":" DUMMY ":" $4}' /etc/shadow > /tmp/shadow.tmp

From the script above, it will only print blah:UMMY: at shadow.tmp
what i need is to print the rest of the users from shadow file including the modified.
e.g:

man:*:13994::::::
nagios:!:13994:0:99999:7:::
named:!:13994:0:99999:7:::
news:*:13994::::::
nobody:*:13994::::::
ntp:!:13994:0:99999:7:::
blah:UMMY:

instead of only blah:UMMY: