# If the folder does not exist, create it, then create the file in that folder
# and add the text.
# If the folder exists and the file dosen't then create the file in that folder
# and add the text.
# If the folder and file exist, then just add the text to the file.
FOLDER="hello4"
FILE="world2.txt"
TEXT_ADDED="Hello World4"
if [ -e "$FOLDER" ]
then
echo "Folder $FOLDER exists"
cd $FOLDER
if [ -e "$FILE" ]
then
echo "File $FILE exists"
echo "$TEXT_ADDED" >> "$FILE"
echo "Added the text '$TEXT_ADDED' to $FILE"
echo "Files currently in folder $FOLDER, $(ls)"
else
touch $FILE
echo "$TEXT_ADDED" >> "$FILE"
echo "Changed directory to $FOLDER, Created $FILE and added the text '$TEXT_ADDED'"
echo "Files currently in folder $FOLDER, $(ls)"
fi
else
mkdir $FOLDER
echo "$TEXT_ADDED" >> "$FOLDER/$FILE"
echo "Created folder and file $FOLDER/$FILE and added the text '$TEXT_ADDED'"
echo "Files currently in folder, $FOLDER $(ls)"
fi