Iam making a program with a fast menu in linux shell.
A option is to edit or to change directory.
I need to see if it is a directory or a file, because i need to use vim for a file and cd for a directory.
Thank you for reading/helping
Iam making a program with a fast menu in linux shell.
A option is to edit or to change directory.
I need to see if it is a directory or a file, because i need to use vim for a file and cd for a directory.
Thank you for reading/helping
echo "Input a file: "
IFS= read -r file
if test -f "$file"
then
echo "$file is a regular file"
elif test -d "$file"
echo "$file is a directory"
else
echo "It's something else, like a socket, fifo or device."
fi
Also, see this post if you cd
but still find yourself in the same directory after your script exits.