Commit a418da43 authored by Alex Segers's avatar Alex Segers

2. Parse Columns

parent 96e44b38
#!/bin/bash
PASSWD_FILE="/etc/passwd"
SEARCH_USER=$1
while read -r ROW || [ -n "$ROW" ];
do
USER=$(echo $ROW | awk -F: '{ print $1 }')
if [[ $USER == $SEARCH_USER ]]
then
HOME_DIR=$(echo $ROW | awk -F: '{ print $6 }')
echo "Home directory: $HOME_DIR"
exit 0
fi
done < $PASSWD_FILE
echo "User \"$SEARCH_USER\" not found"
exit 1
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment