I have cript which search for user files in absolute path, but 开发者_StackOverflownow I need to add for relative also. How can I do this?
#!/usr/local/bin/bash
if [ $# -eq 2 ]; then
DIR=$1
USERNAME=$2
while [ ! $(id -g $USERNAME) ]; do
echo "non-existing username, please add again "
read USERNAME
done
while [ ! -d "/home/$DIR" ]; do
echo "non-existing '$DIR' directory, please add again "
read DIR
done
echo "variable username is now $USERNAME"
echo "variable DIR is now $DIR"
echo -e "username group file"
ls -1Apl /home/$DIR | grep -v /\$ | awk -v user=${USERNAME} '$3==user{print}{}' | tr -s ' ' | cut -d ' ' -f3 -f4 -f9
else
echo "bla"
fi
i don't need damn abolute and relative path with freakin' ls :/ so
while [ ! -d "$DIR" ]; do
and
ls -1Apl $DIR | grep -v /\$
and it is working
精彩评论