Friday, April 1, 2016
Linux Bash Shell Script Recursive Directory Traversal and Permission Removal
April 01, 2016
bash
,
beginner
,
code
,
explanation
,
forloop
,
functioncallargument
,
ifcondition
,
linux
,
ls
,
parameters
,
recursivedirectorytraversal
,
recursivefolder
,
removeownerpermission
,
script
,
shell
,
tutorial
How the code below works:
The code below traverses all the directories recursively inside the passed in command line argument directory. While traversing recursively if it finds a regular file with executable permission it remove the permission for the owner.Code To Recursively Traverse Directories and Remove Permission:
Save the code in a file named "RecursiveDirectoryTraversal.sh".Running the Code:
Make sure to cd into that directory if you have not opened the terminal in that directory.Create a folder named "deleteFolder". Inside that create some more and inside them create some files with executable permission set for them. No need to do these thing terminal, it will work either way. Finally, type the code in terminal.
bash RecursiveDirectoryTraversal.sh deleteFolder
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment