Here is one way to do this with Awk, which is relatively easy to understand:
awk '{print substr($0, index($0, $3))}'
This is a simple awk command without a template, so the action inside {} is performed for each line of input.
The action is simply to print a substring starting at the position of the third field.
$0 : entire input line$3 : 3rd fieldindex(in, find) : returns the find position in the in linesubstr(string, start) : return a substring starting at index start
If you want to use another separator, such as a comma, you can specify it with the -F option:
awk -F"," '{print substr($0, index($0, $3))}'
You can also use this in a subset of the input lines by specifying the pattern before the action in {} . Only lines matching the pattern will be executed.
awk 'pattern{print substr($0, index($0, $3))}'
Where the template can be like:
/abcdef/ : use regexp, by default it works at $ 0.$1 ~ /abcdef/ : work in a specific field.$1 == blabla : use string comparisonNR > 1 : use record / line numberNF > 0 : use field / column number
raychi Feb 05 '13 at 19:18 2013-02-05 19:18
source share