How to extract full name?

QuestionsQuestions8 SkillsProYour First Linux LabDec, 08 2025
0117

To extract the full name from the output of the getent command, you can use awk to filter the relevant field. Here's a command that does this:

getent passwd $(whoami) | awk -F: '{print $5}'

Explanation:

  • getent passwd $(whoami): Retrieves the user information for the current user.
  • awk -F:: Sets the field separator to a colon (:).
  • {print $5}: Prints the fifth field, which typically contains the full name.

This command will output the full name associated with the current user. If you have any more questions, feel free to ask!

0 Comments

no data
Be the first to share your comment!