Let’s say you’ve copied a giant chunk of data from a source to destination something like this:
sudo cp From_SOURCE/* To_DESTINATION/
Now you wish to undo this command. Phew!!!
Solution:
This can be achieved using a python script for nerds like us,
#!/usr/bin/env python
import os
source_dir = "/path/to/source" # the folder you copied the files from
target_folder = "/path/to/destination" # the folder you copied the files to
for root, dirs, files in os.walk(source_dir):
for name in files:
try:
os.remove(target_folder+"/"+name)
except FileNotFoundError:
pass
reverse.py
,[sudo] /path/to/reverse.py
First try on a test directory, I’m guessing the damage might be negligible but on your risk again!
Second thing to note:-
In case the source directory has no sub-directories, the script can even be simpler:
#!/usr/bin/env python
import os
source_dir = "/path/to/source" # the folder you copied the files from
target_folder = "/path/to/destination" # the folder you copied the files to
for file in os.listdir(source_dir):
try:
os.remove(target_folder+"/"+file)
except FileNotFoundError:
pass
All files that are present in both src
and dest
can be removed from dest
like this:
find . -maxdepth 1 -type f -exec cmp -s '{}' "$destdir/{}" \; -exec mv -n "$destdir/{}" "$toDelete"/ \;
This is not an ad-vocation by any means for TP-link branding, however a real life…
First of all we need to hit the kernel version on any Android device. You…
Use resolvectl status instead. It's like something deprecates and suddenly things get broken! In systemd…
Geeky question: This is what people and friends have tried: rsync -arv --exclude "/home/john/.ccache:/home/ben/build" /home/john…
You might encounter this error which appears to be very common on Debian based Distro's…
PS: This article is for only Kali Linux users, that too having a Broadcom Wireless…