cut
-d: specifies the delimiter to use
-f: specifies the list of fields
-s: do not print lines not containing delimiters
-c: specifies columns to display (each character is one column)
cat access_log | cut -d' ' -f6 | grep '200' | wc -l

The -d' ' option tells cut to use space as the delimiter instead of the default tab character. And the -f6 option tells cut to grab field number 6.

my $appWriteDB = `grep 'appWriteDB' /etc/mg/setup.conf | cut -f2-3 -d ':'`;

The above sample extracts field 2 and 3. The data for the above sample:

appWriteDB:192.168.20.29:3307
page_revision: 0, last_edited: 1223881101|%e %b %Y, %H:%M %Z (%O ago)
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License