Cut the second and third fields (separated by a colon) from the /etc/passwd file, remove all newline characters, reduce all multiple spaces to single spaces, and replace each pair of characters with a pair of square brackets.
cut -d : -f 2,3 /etc/passwd | tr -d '\n' | tr -s ' ' | sed 's/\([^ ]\) \([^ ]\)/[\1\2]/g'