Skip to content

Instantly share code, notes, and snippets.

@DustinAlandzes
Last active November 4, 2016 22:35
Show Gist options
  • Save DustinAlandzes/68255fe352f1e310f232259e06a4c0da to your computer and use it in GitHub Desktop.
Save DustinAlandzes/68255fe352f1e310f232259e06a4c0da to your computer and use it in GitHub Desktop.
#!/bin/bash
# download with this command:
# curl -O https://gist.githubusercontent.com/f00-/68255fe352f1e310f232259e06a4c0da/raw/7ddd7a9d85ebb20c6b1e31cca993c791f21ec6f4/script4john.sh
# once you have it downloaded
# usage: ./script4john.sh folderYouAreChecking fileYouWantTokeep
# be careful, make sure you specify the right folder and file
# you could potentially rm -rf * somewhere important
# may need to give this file execution permissions, you can do this with chmod:
# chmod +x script4john.sh
#user arguments, $1 = folderYouAreChecking, $2 = fileYouWantToKeep
folder=$1
file=$2
#change directory to the folder specified
cd $folder
#copy the file we want to /tmp
cp $file /tmp/$file
#remove all the files
rm -rf *
#move the file we wanted back from /tmp to . (the current directory)
mv /tmp/$file .
echo success
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment