This is my first go at scripting in Linux. I'm using Red Hat Enterprise Client 5.7.
This test script is to find all files that match the criteria from a find command. Files that are found are passed through the script to have the correct permissions set.
Code:
#!/bin/bash
CorrectPermission=-r--------
ID=$(find /test -name abc -print)
echo $ID
Permisson=$(ls -l $ID | awk '{print $1}')
If there is only one file that meets the criteria of the find command, this works. If there are multiple results, the script fails. The reason it fails is the results from the find command are not parsed to multiple lines, I believe.
I am testing this script against:
Code:
/test/abc
/test/dif/abc
Where the two abc files have incorrect permissions.
Results of executing my script are:
Code:
/test/dif/abc /test/abc
Permissions: -rw-r--r-- -rwxrwxrwx
./test3.scr: line 7: [: too many arguments
Permissions: Incorrect
Updating permissions to: 400
This is not for any school assignment, but for personal understanding. Thank you for any help you can provide.