risp/clean_verification_txt.sh

15 lines
698 B
Bash
Raw Normal View History

#!/bin/bash
sed -i '/^$/d' ~/ris.txt
sed -i '/^Text$/d' ~/ris.txt
sed -i 's/^[ \t]*//;s/[ \t]*$//' ~/ris.txt
sed -i -E ':a;N;$!ba;s/\n(\([0-9]+\))\n/\n\1 /g' ~/ris.txt
sed -i -E ':a;N;$!ba;s/(\n[0-9]+\.)\n/\1 /g' ~/ris.txt
sed -i -E ':a;N;$!ba;s/(\n[0-9]+\))\n/\1 /g' ~/ris.txt
sed -i -E ':a;N;$!ba;s/(\n[a-z]+\))\n/\1 /g' ~/ris.txt
awk '!seen[$0] { lines[$0]=NR } seen[$0] && (NR-lines[$0] <= 5) { delete lines[$0]; lines[$0]=NR } { seen[$0]=1; all[NR]=$0 } END { for (i = 1; i <= NR; i++) if (lines[all[i]] == i) print all[i] }' ~/ris.txt > temp && mv temp ~/ris.txt
awk 'NR==FNR {if (/\.$/) {sub(/\..*$/, "", $0); seen[$0]=1} next} !seen[$0]' ~/ris.txt ~/ris.txt > temp && mv temp ~/ris.txt