One-liners: Difference between revisions
Add a meza one-liner |
compare two wikis for installed extensions and skins |
||
Line 1: | Line 1: | ||
Sometimes one-liners are so cool, you just want to remember them. And good one-liners can also teach you the intricacies and features of the [[Bash]] shell. Although there are better sites on the Internet for [http://www.bashoneliners.com/ finding one-liners], [http://www.catonmat.net/series/bash-one-liners-explained understanding one-liners] or [http://uni.xkcd.com/ playing on the command line], we'd still like to illustrate a few here. | Sometimes one-liners are so cool, you just want to remember them. And good one-liners can also teach you the intricacies and features of the [[Bash]] shell. Although there are better sites on the Internet for [http://www.bashoneliners.com/ finding one-liners], [http://www.catonmat.net/series/bash-one-liners-explained understanding one-liners] or [http://uni.xkcd.com/ playing on the command line], we'd still like to illustrate a few here. | ||
== Compare two wikis for extensions and skins == | |||
This one-liner invokes the API of two wikis asking for info on siteinfo, general, extensions and skins; in json format. Since that data is returned without any newlines, we use `jq` to pretty-print the json output. Then it's an easy `meld` or `diff` to compare them. The `--silent` option to `curl` just suppresses the connection and retrieval metadata; while the `-L` is customary to follow redirects. | |||
<source lang="bash"> | |||
A='https://freephile.org/' B='https://www.mediawiki.org/' API='w/api.php?action=query&meta=siteinfo&siprop=general%7Cextensions%7Cskins&format=json' meld <(curl --silent -L "${A}${API}" | jq '.') <(curl --silent -L "${B}${API}" | jq '.')</source> | |||
== Perl edit == | == Perl edit == |