Skip to content

Instantly share code, notes, and snippets.

@kesor
Created April 6, 2020 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kesor/6aa246d08c2aa2c3b0cfe1fb769e2c51 to your computer and use it in GitHub Desktop.
Save kesor/6aa246d08c2aa2c3b0cfe1fb769e2c51 to your computer and use it in GitHub Desktop.
Remove all the Python files and replace them with a tiny shell script
#!/bin/sh
just_the_file_please() {
sed -e 's!^[^/]*\(/.*\)$!\1!'
}
remove_magic() {
sed -e 's!__pycache__/!!; s!\.[^.]*\.pyc$!.pyc!'
}
python -m compileall -f .
find /app/scapy -type f -name \*.py -exec rm \{\} \+
find /app/scapy -type f -name \*.pyc -ls \
| just_the_file_please | \
while read before_just_a_file; do
after_just_a_file=$(echo $before_just_a_file | remove_magic)
mv $before_just_a_file $after_just_a_file
done
@vinny36
Copy link

vinny36 commented Apr 6, 2020

Thanks for sharing sir . :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment