[Shell Script] Membagi file berdasarkan pola


Kebetulan hari ini saya butuh membagi file berdasarkan pola. Ternyata di shellscript linux kita bisa menggunakan csplit dengan sedikit regex. Misal kita punya file conto.txt:

--potong
satu
dua
--potong
tiga
--potong
empat
lima

dan ingin memotong file tersebut jika ketemu kalimat –potong, maka kita bisa menggunakan bash script :

csplit -z -f c conto.txt '/--potong/' {*}

kita akan dapat file c00, c01,c03 dengan isi yanmerupakan pecahan dari conto.txt

Kehamilan 40 minggu

  1. You’re so interesting! I don’t believe I’ve truly read through something like that before.
    So nice to find another person with a few unique thoughts on this subject matter.
    Seriously.. thanks for starting this up. This web site is something that’s needed on the web, someone
    with a little originality!

  1. No trackbacks yet.

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s