Friday, April 1, 2016
Linux Bash Shell Script File Executable check and Owner permission Removal
April 01, 2016
bash
,
beginner
,
code
,
executable check
,
explanation
,
file type check
,
function argument passing
,
function call
,
function parameters
,
if condition
,
linux
,
owner permission removal
,
script
,
shell
,
tutorial
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
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment