-1

I would like to know how could I filter the result from a large text with Linux command

example text :

dmade Moroccan Rug, Beni Ourain Rug, White & Red Wool","sku":[],"is_vintage":false},{"title":"Moroccan Handmade Rug, Beni Ourain Rug, Sheep Wool Rug, Black And Light Gray Rug, Checkered Rug, Berber Rug, Tapis berbere, Teppish Marokko","sku":[],"is_vintage":false},{"title":"Fabulous Beni Ourain Rug, Moroccan White & Green Rug, Sheep Wool Rug, Checkered Carpet, Handmade Rug, Sheep Wool Rug, Scandinavian Carpet.","sku":[],"is_vintage":false},{"title":"GORGEOUS MOROCCAN RUG,Authentic Rug,Geometric 2x8 Rug, Handmade Carpet,White And Green Vintage Moroccan Rug,Berber Carpet,Handwoven Wool Rug","sku":[],"is_vintage":true},},

I want to extract all title match from the beginning of title expression to the end of title "sku" while the sku expression won't be extracted and organize each title in line.

Dave M
  • 4,514
  • 22
  • 31
  • 30
newbiline
  • 1
  • 1
  • 2
    Use the code blocks to format the text. It's nigh impossible to tell what's going on. Also, edit the question and add the expected output so that it's clear as to what you need. – Nasir Riley Jun 28 '22 at 00:53

1 Answers1

1

This looks like a JSON to me, and an easiest way to deal with JSON from command line is using jq command. You can install jq on any Linux distro. If your file is just a JSON array, you can extract the title values as easy as jq '.[].title' myfile.txt and if you don't need quotes around title just pipe it to tr like this: jq '.[].title' myfile.txt | tr -d '"'

Peter Zhabin
  • 2,696
  • 9
  • 10