开发者

Search for user files in relative and absolute path

开发者 https://www.devze.com 2023-01-24 04:49 出处:网络
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?

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

0

精彩评论

暂无评论...
验证码 换一张
取 消