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

3 thoughts on “Looping to manipulate files content

  1. 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 to jadu Cancel reply