Looping to manipulate files content

Ada tiga file: LB01, LB02, LB03. Masing-masing berisi 10000 baris text, gimana caranya mengambil hanya 10 baris dari masing-masing file?

user@machine $ ls
LB01 LB02 LB02
user@machine $ wc -l LB01 LB02 LB03
10000 LB01
10000 LB02
10000 LB03
user@machine $ ls > list
user@machine $ for i in `cat list`; do tail "$i" > "$i".10; done
user@machine $ ls
LB01 LB02 LB02 LB01.10 LB02.10 LB02.10
user@machine $ wc -l LB01.10 LB02.10 LB03.10
10 LB01.10
10 LB02.10
10 LB03.10

Tagged with: ,
Posted in CodeLog
3 comments on “Looping to manipulate files content
  1. ikhsan says:

    halo, pls put my link on ur blog😀

  2. jadu says:

    I have done some work on text processing as well using awk, send and bash scripting; you might be interested.

    http://unstableme.blogspot.com/

    Thanks.

  3. rasyidmujahid says:

    Thanks Jadu. I’ll try it.
    btw, you might be interested in Windows PowerShell as well. I’m working on windows environment so sometime i use powershell.

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

%d bloggers like this: