This is the culmination of all the bash scripting tutorials. We were to make two scripts that interact with the file system.
./folder-stats-1.sh <dir>
.~/public_html/
and changing them to the appropriate permission. For example, a directory with dr-xr-xr-x
would automatically be changed to drwx--x--x
, a html file is changed to -rwxr--r--
.To summarise, this lab session was not a very happy affair. In fact, quite the opposite. The first excersise took me 50 minutes - the entire lab time, and was done, in my opinion, very poorly with two recursive functions and about 40 lines of code. Now, I could have done it better, but the most important thing is that it works.
folder-stats-2.sh
is a follow-on from the first excersise, and builds on top of that. I now have to add a script that checks and changes permissions. This was a very daunting task from the beginning, and after several hours I stumbled upon ls -R
, which would list all files in long form recursively through the current directory and all child directories. [1] Then it was a case of a heavy amount of regex, along with the cut
command (which also made things much easier) and with some if statements I was finished.
This is very much an easier said than done, and I think that this type of scripting is still slightly beyond me, and I would be much more comfortable doing this in a different scripting langauge with better syntax, like for example Python.