Good day. There was such a problem. The script forms a string.

[[["2c5d5aa063cbd80120ff8c666d8e6032d006ce7f","1","77459"],["","1",""],["","1",""],],[]]

You need to go through the file and delete all ["","1",""], that is, empty values ​​that I do not need. the string should take the form (the number of entries may vary)

 [[["6a826cae5c354769f6ace3659becdea6e24bbcb0", "1", "30000"],["069ac71a9e9946522cbd08d50735a6752a9fe2aa", "1", "17000"],["69a0ad6441314c9e91b885b283310d9786a3fdeb", "1", "30000"],["4509266c765f6c76e0142671c575f81243ea09f1", "1", "30000"],["a5e705c376f61185648cb51f0e62fb9319aca036", "1", "44000"],["a928e660e6ae5e07c031dbcd448379f0e976e11a", "1", "23000"],["c1455a28696c05d29dbcc52a6b7c0b2cf6d69d28", "1", "21000"],["ed2a033e270dd240903a1e039d388324aedc5f63", "1", "32000"],["f905d4e71b253d6fe3e77f2abc33d21412805c8b", "1", "77000"]], []] 

The value in the string, respectively, may be different and should not change after the script

  • one
    sed 's/\["","1",""\],\?//g' имя-файла is Mike

1 answer 1

 sed -r 's/\["","1",""\],? *//g' -i filename 

If you need to remove extra commas before the closing bracket:

 sed -r 's/\["","1",""\],? *//g; s/,\]/]/g' -i filename 
  • Ok, works. Thank. - Evgeniy A
  • The incoming stream is very similar to JSON or Python lists, it is easier and more correct to do a format parsing, and then process it. - 0andriy
  • @AndyShevchenko give an example of how to implement it in the shell - sercxjo
  • I did not specify about the shell, the shell for this is just an awkward (incorrectly selected) tool. - 0andriy
  • @AndyShevchenko, the task from one file to get another, nothing else needs to be done, your option will take, in any case, more lines and time for programming. - sercxjo