Is it possible to refer to an error? Here is my code:
read dir mkdir /Users/Dillon/$dirAnd if the directory is already there, it tells me mkdir: /Users/Dillon/(dir): File exists . Is there a way to state that if it already exists to not not show error?
You can test for directory existence before running the command:
[ -d /Users/Dillon/$dir ] || mkdir /Users/Dillon/$dirAlternately, you can use the -p flag:
mkdir -p /Users/Dillon/$dirThis will make the directory if it does not yet exist, as well as any missing directories in the path. It does not complain if the directory already exists. It will complain if any segment of the path exists, but isn't a directory or a symlink to a directory.