0

I've recently started to learn bash script and have started to create a file repository system. I have gotten pretty far and am able to add files, remove files. When I remove a file from the repository it actually leaves the file in but changes permissions so only the user that removed can use it, it then send a copy to there home area, it also changes the name of the file left behind to "$fileNameOUT"

I know plan to add a feature to my add function which checks after a file has been added if there is a file with the same name but with "OUT" at the end, if it finds this the old file will be sent to a back folder so files can be restored. I know I have to loop through the directory using a for loop, however the problem I'm having is I don't know how I can compare the file I have just added to all of the files in the directory.

I hope someone can make send of what I just wrote.

1
  • I hope someone can make send of what I just wrote. -- To be honest, it's pretty tough. Commented Oct 13, 2013 at 11:57

1 Answer 1

1

If you know the name of the file you are interested in, you can use the -e test to check if it exists.

if [ -e fooOUT ]
then
echo File exists
fi
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.