From 238a1241d207eaa896460ab6f26be3899114c9fa Mon Sep 17 00:00:00 2001 From: Mike Farah Date: Wed, 27 Mar 2019 09:27:07 +1100 Subject: [PATCH] Added snap specific notes https://forum.snapcraft.io/t/requesting-classic-confinement-for-yq/10559 --- README.md | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a825009..a9d9472 100644 --- a/README.md +++ b/README.md @@ -8,21 +8,40 @@ a lightweight and portable command-line YAML processor The aim of the project is to be the [jq](https://github.com/stedolan/jq) or sed of yaml files. ## Install -On MacOS: +### On MacOS: ``` brew install yq ``` -On Ubuntu and other Linux distros supporting `snap` packages: +### On Ubuntu and other Linux distros supporting `snap` packages: ``` snap install yq ``` -On Ubuntu 16.04 or higher from Debian package: + +#### Snap notes +`yq` installs with with [_strict confinement_](https://docs.snapcraft.io/snap-confinement/6233) in snap, this means it doesn't have direct access to root files. To read root files you can: + +``` +sudo cat /etc/myfile | yq -r - somecommand +``` + +And to write to a root file you can either use [sponge](https://linux.die.net/man/1/sponge): +``` +sudo cat /etc/myfile | yq -r - somecommand | sudo sponge /etc/myfile +``` +or write to a temporary file: +``` +sudo cat /etc/myfile | yq -r - somecommand | sudo tee /etc/myfile.tmp +sudo mv /etc/myfile.tmp /etc/myfile +rm /etc/myfile.tmp +``` + +### On Ubuntu 16.04 or higher from Debian package: ``` sudo add-apt-repository ppa:rmescandon/yq sudo apt update sudo apt install yq -y ``` -or, [Download latest binary](https://github.com/mikefarah/yq/releases/latest) or alternatively: +### or, [Download latest binary](https://github.com/mikefarah/yq/releases/latest) or alternatively: ``` go get gopkg.in/mikefarah/yq.v2 ```