Skip to main content

All Questions

0 votes
2 answers
2k views

Get json value using regex in linux bash

I have a json file file.json like this: { "abc": "123", "def": 456, "ghi": 789 } I am trying to get value of all the keys using regex in bash terminal. ...
mmk's user avatar
  • 111
0 votes
1 answer
176 views

Find and replace everything inside bracket using unix shell - several lines

I need to find and replace a big part of a json file using shell. For exemple I have this file : { "Balise1": true, "Balise2": true, "OtherThingEnabled": false, ...
Raph04's user avatar
  • 3
0 votes
3 answers
2k views

Regex to match JSON in an HTML

From this JSON-HTML webpage I want to filter out only lines with this pattern: "realname": "SOME_VALUE_COMES_HERE", I tried this: curl https://www.mediawiki.org/w/api.php?action=...
Lahor's user avatar
  • 123
0 votes
1 answer
365 views

Write sed command to input file

I'm building a script to automate boilerplate. In it, I append a string: "compile": "browserify js/main.js > ./dist/bundle.js -t babelify", "watch": "watchify js/*...
BuddhiLW's user avatar
  • 143
0 votes
1 answer
696 views

Delete text from files using regex with sed

I'm attempting to use sed to remove some lines from json files. As you can probably tell, I'm very much an amateur but think I have the regex correct. However sed throws various errors including ...
Danny P's user avatar
0 votes
3 answers
565 views

How should I replace a number in a JSON file with its MD5 hash using sed command?

I have a big log file in JSON format containing a line as below example : {"data_1":210,"target_number":1096748811,"extra_data":66} {"data_1":0,"...
LuFFy's user avatar
  • 139
1 vote
2 answers
22k views

Parse curl response with sed

I'm trying to call a JSON API with the following curl command on macOS: curl https://api.ipify.org?format=json It returns something like this: {"ip":"xxx.xxx.xxx.xxx"} I would like to extract the ...
Imnl's user avatar
  • 141
2 votes
1 answer
340 views

Using subset in sed for replace with regex

Consider some data that looks like this: "2019-12-12 00:00:01","2012-01-01 01:01:01" I wish to replace it so that they are valid datetime json values: "2019-12-12T00:00:01+01","2012-01-01T01:01:01+...
paul23's user avatar
  • 123
1 vote
1 answer
649 views

How to grep multiple lines?

Grep understands this : curl https://api.coinmarketcap.com/v1/ticker/ | grep "clipper-coin" But not this : curl https://api.coinmarketcap.com/v1/ticker/ | grep "{*clipper-coin*}" The output I ...
pxoto's user avatar
  • 183
0 votes
3 answers
653 views

Linux sed command replace two lines having spaces and special characters using regular expression

I have one file having following example text. "list-value": { "object-value": { "value": "example-value-123" } } I want to change value text "example-value-123" by matching pattern ...
Oomph Fortuity's user avatar
-1 votes
1 answer
107 views

Minimized JSON code between two patterns with regex

Let's take a file with for example : "test": [ { } ], "test": [ ...
bob dylan's user avatar
  • 1,952
1 vote
3 answers
7k views

Extract UUID value from JSON returned from HTTP reply

I am trying to make a little script in shellscript that takes one serviceUuid from a response and use it. I just print the server response on a file called final.txt Now i need to extract the value ...
op32's user avatar
  • 31
4 votes
2 answers
2k views

grab text out of vtt file

vtt files look like this: WEBVTT 1 00:00:00.096 --> 00:00:05.047 you're the four functions if you would of management first of all you have the planning 2 00:00:06.002 --> 00:00:10.079 the ...
AwokeKnowing's user avatar
1 vote
3 answers
566 views

Overcoming newlines with grep -o

I have a file similar to such: { "1": { "state": "RUNNING", "stats": { "name": "some-file", "uris": [ ...
Izy-'s user avatar
  • 141
5 votes
2 answers
12k views

sed to match zero or more number of spaces in a string

function getVal { sedPattern='s/^.*"keyVal":"\([^"]*\)".*$/\1/' finalSedPattern=${sedPattern/keyVal/$2} echo $(sed $finalSedPattern <<< $1) } This is my Json parser written using sed. ...
user avatar

15 30 50 per page