iiitl / bash-practice-repo-24

0 stars 35 forks source link

#4 Added rm-bins script. #125

Closed Priyanshu-2005 closed 5 months ago

Priyanshu-2005 commented 5 months ago

Fixes #4 Added rm-bins script

*Before running the script** Command Used tree image

For running the script Command used: bash rm-bins It would delete all the executable files. image

After running the script Commands used: tree image

Reverted all the changes so that they are not commited and again wrote the code and then published the branch and then made the pull request.

Explanation of code: find . -type f -executable This command starts to find in the current directory for files that are marked as executable.

exec file ;: For each file found by the find command, the -exec option executes the file command on it.

grep "executable": The output is then piped to grep, which then filters the lines containing "executable". This is done to identify the files that file considers to be executable.

cut -d:' : This effectively extracts the filenames from the file command's output.

xargs rm -f: Finally, the extracted filenames are piped to xargs, which constructs and executes rm -f commands to forcefully remove each file.

rootCircle commented 5 months ago

your implementation remove executables not binaries, but I will allow it! (hint: ELF)

Accepted!