Use bash awk sed to extract text field in file -
i have file (odd lines , lines have different type content):
try upload ui/uploaded/2010.png [{"index":"1","field":"file","exloc":"mivip/07fb"}] try upload ui/uploaded/2011.png [{"index":"1","field":"file","exloc":"mivip/0487"}]
what want is:
2010.png mivip/07fb 2011.png mivip/0487
and further more, want result output array(for latter code use). want use bash(awk,sed used if need) this.
when use awk, not figure out right regular expression field separator(i want use , space : " [ ] { , } field separator, last field want). best answer giving right separator awk.
or fallback sed(replace , " [ ] { } space).
easy in sed:
sed -e '/^try upload/s=.*/==; /^\[/{s=.*"exloc":"==;s="}\]==}'
it uses called "addresses", translates to: if line starts "try upload", remove last slash. if line starts [
, remove "exloc":"
, , remove trailing "}]
.
Comments
Post a Comment