How to test whether a file exist in shell on Linux? We can use the test command to check file types and whether it exits.
How to test whether a path is a regular file in shell on Linux
We can use the following command to test whether a path is a regular file and exist.
1 2 3 4 |
test -f some_file if [[ $? == 0 ]] ; then echo "some_file is a file and exist" fi |
How to test whether a path is a folder in shell
Using the following command, we can test whether a path is a folder in shell on linux.
1 2 3 4 |
test -d some_folder if [[ $? == 0 ]] ; then echo "some_folder is a folder and exist" fi |
How to test whether a file is a symbolic link on linux?
[Read More...]