Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
writing a script that looks up a username in the password file?
I am working on script that looks up a given username in the system's /etc/passwd file, producing on the command line the user's real name. I was wondering what the best way was to do this because I am not sure how to approach it. Any help would be great.
1 Answer
- potatocouchLv 510 years agoFavorite Answer
that file is split into parts by colons. therefore, you can grep to grab the right line and then awk to grab the right field. let's say the "real name" column is the 8th one.
grep the_username /etc/passwd | awk -F: '{print $8}'
in your script you'll replace the_username by the variable that was inputted, eg $input_username