Friday, April 1, 2016

Linux Bash Shell Script File Executable check and Owner permission Removal


How the code below works:

The code below checks if the given command line argument is a regular file. If it is then it checks if the file is executable. Finally if the file is executable the code removes the execution permission for the owner.

Code To Check File Type & Remove Permission:

Save the code in a file named "FileCheckPermissionRemove.sh".

Running the Code:

Make sure to cd into that directory if you have not opened the terminal in that directory.

Create a dummy shell script named "abc.sh" and set its permission to executable. Finally type the code in terminal.

bash FileCheckPermissionRemove.sh abc.sh

No comments: