I'm new to scripting in bash and would like to retrieve all user names of a Linux system along with their home directories. Each username got to be in a single line. Is this is the best way to do this? or is there any better way?
#! /bin/bash
# list all users accounts using the /etc/passwd file
cat /etc/passwd | awk -F: '{print $1," ",$6}'
I ask you kindly to advise
As @chepner commented, awk -F: '{print $1," ",$6}' /etc/passwd is better.
You can try the following :
It's a a python script which takes as input /etc/password file, and return a JSON list as bellow.