Home > Uncategorized > JSON pattern matching with sed, perl and regular expressions

JSON pattern matching with sed, perl and regular expressions

Vlad Mihalcea's Blog

Why VIM?

Sooner or later there comes the day when your easy-to-use IDE becomes useless for handling huge files. There aren’t many editors capable of working with very large files, like production logs for instance.

I’ve recently had to analyze a 100 MB one-line JSON file and once more VIM saved the day. VIM, like many other Unix utilities, is both tough and brilliant. Git interactive rebase requires you to know it, and if you’re still not convinced, maybe this great article will make you change your mind.

Let’s see how easily you can pretty print a JSON file with VIM. First we will download a one-line JSON file from Reddit.

This is how it looks like:

vim_json_one_line

Pretty printing

Python comes along with most Unix distributions, so running the following VIM command manages to do the trick:

vim_json_pretty

Let’s save the pretty printed JSON file and put other Unix tools to…

View original post 131 more words

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: