Shell scripting problem

Hello. I hava homework for university but i cant do it and i need a little help if someone can help me :slight_smile: I have to do a linux shell script.
Write a script that does the following:

  1. Check if there is a directory in / home with myDir name.
    If not, it creates it.
  2. In the directory it creates a new myFile file, checking if the user,
    triggered the script, has write permissions on that file, if it does not, it outputs
    Error message.
  3. If there is, record the names, faculty numbers, and group of the file in the file
    team members.
  4. Shows the contents of the file on the screen by numbering the rows and how many
    times the script has been started so far.

#!/bin/bash
if (! dir -d myDir); then
sudo mkdir myDir
else echo "The folder already exist!"
fi
cd myDir && sudo touch myFile2

I done 1. but on the 2. when i create the file i dont know how to chek for permissions and how to do it can someone help me please ? :slight_smile:

Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulted in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.