check to see if filepath exists bash linux script

Viewed 269

Hi I had a question how to how write a script that would first check to see if a given filepath exists and if so outputs the path in readable sentences. I was going to start with

if [ -e "$1" -a -d "$1" ]; then
  echo $PATH 
else 
  echo "Path does not exist"
fi

so basically I'm just a little confuse on when I run my script ./myscript filename how exactly filename gets passed into $1 so I can check to see if it exists. I was also wondering how to do this to see if a user exists on the system. Any help is greatly appreciated!

0 Answers
Related