Question: I have a question. Assuming I dump a file and do a grep for foo and comes out the result like this:

```

Foo-bar-120:'foo name 1'
Foo-bar-130:'foo name 2'
Foo-bar-1222:'foo name 3'

```

Etc.

All I want is trying to extract the foo name with largest number. For instance in this case, largest number is 1222 and the result I expect is `foo name 3`

Is there a easy way using awk and sed to achieve this? Rather than pull the number out line by line and loop through to find the largest number?

Answer: 
Assuming the line format is as shown with 2 hyphens before "the number":

```
cut -d- -f3- | sort -rn | sed '1{s/^[0-9]\+://; q}'

```
You don't need to use `grep`. you can use `awk` directly on your file as:

```
awk -F"[-:]" '/Foo/ && $3>prev{val=$NF;prev=$3}END{print val}' file

```