![]() ![]() Is a useful one-liner which will give you the full directory name of the script no matter where it is being called from. If the variables contain spaces or other unusual characters it will probably cause the script to fail. The reason for this is explained by 8jean in another answer. Take particular note of the double-quotes used to wrap the variables. # Symbolic link specific commands go here. So symbolic links may have to be treated differently, if subsequent commands expect directories: if then ![]() Will produce the error message: rmdir: failed to remove `symlink': Not a directory running this: ln -s "$ACTUAL_DIR" "$SYMLINK" However, as Jon Ericson points out, subsequent commands may not work as intended if you do not take into account that a symbolic link to a directory will also pass this check.Į.g. # Control will enter here if $DIRECTORY doesn't exist. Or to check if a directory doesn't exist: if then # Control will enter here if $DIRECTORY exists. To check if a directory exists in a shell script, you can use the following: if then ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |