Created
July 19, 2021 20:43
-
-
Save theagoliveira/1259c206f2d084e3fe7f3b73f3b7ae18 to your computer and use it in GitHub Desktop.
WhatsApp messages backup scripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
old="$1" | |
new="$2" | |
olddate=$(echo "$old" | sed -re "s/^.*?([0-9]{4}-[0-9]{2}-[0-9]{2})\.txt/\\1/g") | |
newdate=$(tail -1 "$new" | sed -re "s/^([0-9]*)\\/([0-9]*)\\/([0-9]*).*/20\\3-\\1-\\2/g" | sed -re "s/-([0-9])-/-0\\1-/g" | sed -re "s/-([0-9])$/-0\\1/g") | |
echo $old | |
echo $new | |
echo $olddate | |
echo ${3:-$newdate} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
old="$1" | |
new="$2" | |
olddate=$(echo "$old" | sed -re "s/^.*?([0-9]{4}-[0-9]{2}-[0-9]{2})\.txt/\\1/g") | |
newdate=$(tail -1 "$new" | sed -re "s/^([0-9]*)\\/([0-9]*)\\/([0-9]*).*/20\\3-\\1-\\2/g" | sed -re "s/-([0-9])-/-0\\1-/g" | sed -re "s/-([0-9])$/-0\\1/g") | |
cat "$old" "$new" >> "${old%%$olddate.txt}${3:-$newdate}.txt" | |
rm -rf "$old" "$new" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment