Etenkin sanalistoja yhdistellessä (hakiessa samaa sanaa tai sanaparia kahdelta eri listalta) on tarpeellista saada sanat suunnilleen samaan "formaattiin" ja merkkisiivous.sh on siihen tarkoitukseen laatimani edistyksellinen shell-skripti.
Vaatii toimiakseen paketin icu-devtools asennettuna.
Skripti on tässä:
#!/usr/bin/env bash # # HUOM! SKRIPTI VAATII TOIMIAKSEEN paketin icu-devtools asennettuna. # # Skripti muuttaa tiedoston isot kirjaimet pieniksi ja suurimman osan # erikoismerkeistä, kyrillisistä kirjaimista, html-koodin jäänteistä ja # "mojibakeista" tavallisiksi aakkosiksi tai aakkospareiksi (ß -> ss ja # æ -> ae ja niin edelleen). Myös perusskandit muutetaan. # # Käyttöohje: # 1. Tee tyhjä hakemisto # 2. Laita haluamasi tiedosto nimellä tiedosto.txt siihen # 3. Laita myös tämä skripti sinne nimellä merkkisiivous.sh # 4. Kirjoita chmod +x merkkisiivous.sh # 5. Kirjoita ./merkkisiivous.sh # # Alkuperäisestä tiedosto.txt:stä tehdään # tiedosto_merkkisiivous_bak.txt -niminen varmuuskopio ensin. Itse # tiedosto.txt muuttuu sisällöltään niin, että se siivotaan # erikoismerkeistä ja isoista kirjaimista. # # Tämän on alkujaan kyhännyt Toti joulukuussa 2025 ja tämä on # päivitetty 4. versio (29.1.2026). # echo echo "Vaihe 1/6" echo "Luodaan varmuuskopio alkuperäisestä tiedostosta" echo cp tiedosto.txt tiedosto_merkkisiivous_bak.txt echo echo "Vaihe 2/6" echo "Korjataan tavalliset suomalaiset mojibaket" echo sed -i -e 's/Ä/a/g' tiedosto.txt sed -i -e 's/Ã…/a/g' tiedosto.txt sed -i -e 's/ã¤/a/g' tiedosto.txt sed -i -e 's/ä/a/g' tiedosto.txt sed -i -e 's/Ã¥/a/g' tiedosto.txt sed -i -e 's/Ö/o/g' tiedosto.txt sed -i -e 's/ö/o/g' tiedosto.txt echo echo "Vaihe 3/6" echo "Muutetaan kyrilliset kirjaimet latinalaisiksi" echo uconv -x cyrillic-latin tiedosto.txt -o tiedosto_temp1.txt rm tiedosto.txt echo echo "Vaihe 4/6" echo "Muutetaan erikoismerkit (ä, ö, ü ym.) latinalaisiksi kirjaimiksi (a-z)" echo iconv -f UTF-8 -t ASCII//TRANSLIT tiedosto_temp1.txt > tiedosto_temp2.txt rm tiedosto_temp1.txt echo echo "Vaihe 5/6" echo "Muutetaan kaikki kirjaimet pieniksi" echo tr '[:upper:]' '[:lower:]' < tiedosto_temp2.txt > tiedosto.txt rm tiedosto_temp2.txt echo echo "Vaihe 6/6" echo "Muutetaan HTML-koodi kirjaimiksi" echo sed -i -e 's/'/’/g' tiedosto.txt sed -i -e 's/À/a/g' tiedosto.txt sed -i -e 's/Á/a/g' tiedosto.txt sed -i -e 's/Â/a/g' tiedosto.txt sed -i -e 's/Ã/a/g' tiedosto.txt sed -i -e 's/Ä/a/g' tiedosto.txt sed -i -e 's/Å/a/g' tiedosto.txt sed -i -e 's/Æ/ae/g' tiedosto.txt sed -i -e 's/Ç/c/g' tiedosto.txt sed -i -e 's/È/e/g' tiedosto.txt sed -i -e 's/É/e/g' tiedosto.txt sed -i -e 's/Ê/e/g' tiedosto.txt sed -i -e 's/Ë/e/g' tiedosto.txt sed -i -e 's/Ì/i/g' tiedosto.txt sed -i -e 's/Í/i/g' tiedosto.txt sed -i -e 's/Î/i/g' tiedosto.txt sed -i -e 's/Ï/i/g' tiedosto.txt sed -i -e 's/Ñ/n/g' tiedosto.txt sed -i -e 's/Ò/o/g' tiedosto.txt sed -i -e 's/Ó/o/g' tiedosto.txt sed -i -e 's/Ô/o/g' tiedosto.txt sed -i -e 's/Õ/o/g' tiedosto.txt sed -i -e 's/Ö/o/g' tiedosto.txt sed -i -e 's/Ø/o/g' tiedosto.txt sed -i -e 's/Ù/u/g' tiedosto.txt sed -i -e 's/Ú/u/g' tiedosto.txt sed -i -e 's/Û/u/g' tiedosto.txt sed -i -e 's/Ü/u/g' tiedosto.txt sed -i -e 's/ß/ss/g' tiedosto.txt sed -i -e 's/à/a/g' tiedosto.txt sed -i -e 's/á/a/g' tiedosto.txt sed -i -e 's/â/a/g' tiedosto.txt sed -i -e 's/ã/a/g' tiedosto.txt sed -i -e 's/ä/a/g' tiedosto.txt sed -i -e 's/å/a/g' tiedosto.txt sed -i -e 's/æ/ae/g' tiedosto.txt sed -i -e 's/ç/c/g' tiedosto.txt sed -i -e 's/è/e/g' tiedosto.txt sed -i -e 's/é/e/g' tiedosto.txt sed -i -e 's/ê/e/g' tiedosto.txt sed -i -e 's/ë/e/g' tiedosto.txt sed -i -e 's/ì/i/g' tiedosto.txt sed -i -e 's/í/i/g' tiedosto.txt sed -i -e 's/î/i/g' tiedosto.txt sed -i -e 's/ï/i/g' tiedosto.txt sed -i -e 's/ñ/n/g' tiedosto.txt sed -i -e 's/ò/o/g' tiedosto.txt sed -i -e 's/ó/o/g' tiedosto.txt sed -i -e 's/ô/o/g' tiedosto.txt sed -i -e 's/õ/o/g' tiedosto.txt sed -i -e 's/ö/o/g' tiedosto.txt sed -i -e 's/ø/o/g' tiedosto.txt sed -i -e 's/ù/u/g' tiedosto.txt sed -i -e 's/ú/u/g' tiedosto.txt sed -i -e 's/û/u/g' tiedosto.txt sed -i -e 's/ü/u/g' tiedosto.txt sed -i -e 's/á/a/g' tiedosto.txt sed -i -e 's/â/a/g' tiedosto.txt sed -i -e 's/æ/ae/g' tiedosto.txt sed -i -e 's/à/a/g' tiedosto.txt sed -i -e 's/å/a/g' tiedosto.txt sed -i -e 's/ã/a/g' tiedosto.txt sed -i -e 's/ä/a/g' tiedosto.txt sed -i -e 's/ç/c/g' tiedosto.txt sed -i -e 's/é/e/g' tiedosto.txt sed -i -e 's/ê/e/g' tiedosto.txt sed -i -e 's/è/e/g' tiedosto.txt sed -i -e 's/ë/e/g' tiedosto.txt sed -i -e 's/í/i/g' tiedosto.txt sed -i -e 's/î/i/g' tiedosto.txt sed -i -e 's/ì/i/g' tiedosto.txt sed -i -e 's/ï/i/g' tiedosto.txt sed -i -e 's/ñ/n/g' tiedosto.txt sed -i -e 's/ó/o/g' tiedosto.txt sed -i -e 's/ô/o/g' tiedosto.txt sed -i -e 's/ò/o/g' tiedosto.txt sed -i -e 's/ø/o/g' tiedosto.txt sed -i -e 's/õ/o/g' tiedosto.txt sed -i -e 's/ö/o/g' tiedosto.txt sed -i -e 's/ß/ss/g' tiedosto.txt sed -i -e 's/ú/u/g' tiedosto.txt sed -i -e 's/û/u/g' tiedosto.txt sed -i -e 's/ù/u/g' tiedosto.txt sed -i -e 's/ü/u/g' tiedosto.txt echo echo "Valmista! Tiedoston merkit siivottu." echo