Hello. I hava homework for university but i cant do it and i need a little help if someone can help me
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 ?