I need a sed solution for the work I am doing. I need to extract the name from /etc/passwd file based on the AIX user id (username). So far I have this and it isn't working. Any working solution would be appreciated.
sed "/^Ravi02/s/\(^.\{21\}\).\([a-zA-Z]\{50\}\)/\1/p" /export/home/Ravi02/passwd Here are some example entries from the passwd file:
Jose01:!:49030:49082:Freeman, Joseph III:/export/home/p1jxf01:/bin/ksh Ravi02:!:37242:1580:Dronavalli, Ravi:/export/home/j1rxd02:/bin/ksh Beny01:!:49335:49040:Young, Ben:/export/home/p1bmy01:/bin/ksh Based on the id I need to extract the name. If the id is "Jose01" I should get "Freeman, Joseph III" or if it the id is "Ravi02" then I should get "Dronavalli, Ravi".
sed? Wouldawkor other tools also be acceptable?lsuserinstead?grep "^Ravi02:" /etc/passwd | cut -d: -f5.