Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
get user name with shell script
#!/usr/bin/env bash
# -*- coding=utf-8 -*-
# Author: 易思龙 <ixxoo.me@gmail.com>
# Create: 2015-06-03
username=${USER}
if [ "$username" == "" ]; then
username=`cat /etc/passwd | awk -F':' '{if ($3 == test) {print $1}}' test=$(id -u)`
fi
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.