Skip to content

Instantly share code, notes, and snippets.

@theagoliveira
Created July 19, 2021 20:43
Show Gist options
  • Save theagoliveira/1259c206f2d084e3fe7f3b73f3b7ae18 to your computer and use it in GitHub Desktop.
Save theagoliveira/1259c206f2d084e3fe7f3b73f3b7ae18 to your computer and use it in GitHub Desktop.
WhatsApp messages backup scripts
#!/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}
#!/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