Question: I have a text file which is of the following format:

```
{
Name: Me
Age:17
Qualification : Doctor
}
{
 Name: You
 Age:21
 Qualification : Another Doctor
}

```

I need to copy the number in the Age lines, '17' and '21' in this case, to another file in this format:

```
17,21.

```

As you can see i am trying to create a File 2 CSV of the numbers in a certain field in File 1. I need to automate this using shell script. Kindly suggest a solution to this.

When I searched on Google, the 'sed' option turned up but I could not figure out a compact solution for this problem.

Thanks in advance for your time and contributions.

Answer: 
Some like this?

```
awk -F: '/Age/ {printf "%s,",$2} END {print ""}' file1 >agefile
cat agefile
17,21,

```
This might work for you (GNU sed):

```
sed '/\s*Age:\s*/H;$!d;x;s///;s//,/g' file

```

This appends the lines with `Age:` to the hold space (HS) and deletes everything else. On end-of-file it swaps to the HS and removes the unwanted text replacing it with `,`'s.