Over a million developers have joined DZone.

Cut Blank(s) Separated Fields In Text File On Windows

·
The code (!) :

echo @ruby -ne "puts $_.split(/\s+/)[%1].join(' ')" > rcut.bat


When a file look like :


127.0.0.1 -  -  [16/ao¹t/2011:23:40:15 +0000] "GET / HTTP/1.1" 200 673 "-" "Ruby"
127.0.0.1 -  -  [16/ao¹t/2011:23:42:25 +0000] "GET / HTTP/1.1" 200 673 "-" "Ruby"
. . . . 


Then we can do :

> find "10.177.235" request.log | rcut 0..4
10.177.235.213 - - [24/ao¹t/2011:14:11:19 +0000]
10.177.235.213 - - [24/ao¹t/2011:14:11:19 +0000]
10.177.235.177 - - [24/ao¹t/2011:14:27:28 +0000]
10.177.235.177 - - [24/ao¹t/2011:14:27:28 +0000]
10.177.235.177 - - [24/ao¹t/2011:14:27:28 +0000]

Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}