Find and sed (4)

Meneruskan tulisan sebelumnya soal perintah find dan sed.

Prinsip dasar:

find ./ *.tex -type f -exec sed -i -e 's/OLD/NEW/g' {} \;

Kalau bingung, ketik saja man find atau man sed.

Contoh:

  1. Mengubah ini/ituini atau itu
    find ./ *.tex -type f -exec sed -i -e 's/ini\/itu/ini atau itu/g' {} \;
    
  2. Mengganti aku & kamuaku dan kamu
    find ./ *.tex -type f -exec sed -i -e 's/aku & kamu/aku dan kamu/g' {} \;
    
  3. Mengganti "zonder"zonder
    find ./ *.tex -type f -exec sed -i -e 's/"zonder"/zonder/g' {} \;
    
  4. Mengganti tanya?seru!
    find ./ *.tex -type f -exec sed -i -e 's/tanya?/seru!/g' {} \;
    
  5. Mengganti {./img/gambar}{gambar}
    find ./ *.tex -type f -exec sed -i -e 's/{.\/img\//\{/g' {} \;
    
  6. PS: yang dikasih escape character (\) cuma tanda miring (/).

  7. Mengganti [image]image
    find ./ *.tex -type f -exec sed -i -e 's/\[image\]/image/g' {} \;
    
  8. Mengganti {image}image
    find ./ *.tex -type f -exec sed -i -e 's/{image}/image/g' {} \;
    
  9. PS: sesuai diskusi di sini, curly braces aka kurung kurawal {...} tak perlu diberi escape character.

  10. Mengganti \emph{hello}\textbf{hello}
    find ./ *.tex -type f -exec sed -i -e 's/\\emph{hello}/\\textbf{hello}/g' {} \;
    
  11. Mengganti \textit\emph
    find ./ *.tex -type f -exec sed -i -e 's/\\textit/\\emph/g' {} \;
    

Baca juga:

Selamat mencoba. Semoga bermanfaat.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s