Use bash awk sed to extract text field in file

I have a file like this (odd lines and even lines have different type content):

— File Begin —

try to upload UI/uploaded/2010.png

[{“index”:”1″,”field”:”file”,”exloc”:”MiVip/07fbde4d3abe340e22703f96494bf61e215995e3d”}]

try to upload UI/uploaded/2011.png

[{“index”:”1″,”field”:”file”,”exloc”:”MiVip/048734395a6442854877102d8f0a16ae4f642eaf8″}]

— File End —

What I want to get is:
2010.png
MiVip/07fbde4d3abe340e22703f96494bf61e215995e3d
2011.png
MiVip/048734395a6442854877102d8f0a16ae4f642eaf8

I want to use bash(awk,sed could be used if need) to do this.

When I use awk, I could not figure out the right regular expression for
field separator(I want to use , space : ” [ ] { and } for field separator, so the last field will be what I want).
The best answer will be giving the right separator for awk.

Or fallback to sed(replace all the , ” [ ] { } to space).


Source: bash

Leave a Reply