Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
get user name with shell script
#!/usr/bin/env bash
# -*- coding=utf-8 -*-
# Author: 易思龙 <>
# Create: 2015-06-03
if [ "$username" == "" ]; then
username=`cat /etc/passwd | awk -F':' '{if ($3 == test) {print $1}}' test=$(id -u)`
echo $username
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.