AS SELF STUDY LEARNER I TRIED SOLVE THIS IN AWK CHAPTER OF MY LINUX/UNIX BOOK
12.1 Display from /etc/passwd a list of users and their shells for those using the
Korn shell or Bash. Order the output by the absolute pathname of the shell used.
I came with this ... but sort missing - any help can provided ...? Cent OS 7
awk -F: '($7 ~ /bash/ || $7 ~ /korn/)' /etc/passwd
awk - Korn shell or Bash. Order the output by the absolute pathname of the shell used.
Re: awk - Korn shell or Bash. Order the output by the absolute pathname of the shell used.
Does this work:
awk -F: '($7 ~ /bash/ || $7 ~ /korn/)' /etc/passwd | sort -t: -k7
BTW: korn is /bin/ksh
awk -F: '($7 ~ /bash/ || $7 ~ /korn/)' /etc/passwd | sort -t: -k7
BTW: korn is /bin/ksh
Re: awk - Korn shell or Bash. Order the output by the absolute pathname of the shell used.
[bob@server1 ~]$ awk -F: '($7 ~ /bash/ || $7 ~ /halt/)' /etc/passwd | sort -t: -k7
bob1005:1006::/home/bob:/bin/bash
root0:0:root:/root:/bin/bash
tux1000:1000:tux:/home/tux:/bin/bash
halt7:0:halt:/sbin:/sbin/halt
[bob@server1 ~]$
MUST WORKED THANKS
I did Not have ksh and put halt that had
bob1005:1006::/home/bob:/bin/bash
root0:0:root:/root:/bin/bash
tux1000:1000:tux:/home/tux:/bin/bash
halt7:0:halt:/sbin:/sbin/halt
[bob@server1 ~]$
MUST WORKED THANKS
I did Not have ksh and put halt that had
Re: awk - Korn shell or Bash. Order the output by the absolute pathname of the shell used.
[bob@server1 ~]$ awk -F: '($7 ~ /bash/ || $7 ~ /halt/)' /etc/passwd | sort -t: -k3
root0:0:root:/root:/bin/bash
tux1000:1000:tux:/home/tux:/bin/bash
bob1005:1006::/home/bob:/bin/bash
halt7:0:halt:/sbin:/sbin/halt
[bob@server1 ~]$
root0:0:root:/root:/bin/bash
tux1000:1000:tux:/home/tux:/bin/bash
bob1005:1006::/home/bob:/bin/bash
halt7:0:halt:/sbin:/sbin/halt
[bob@server1 ~]$
Re: awk - Korn shell or Bash. Order the output by the absolute pathname of the shell used.
Though that's not strictly doing what the question asked: "Display from /etc/passwd a list of users and their shells". Yes, the info they ask for is there but you are also displaying the entire line not jsut those 2 requested fields.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke