sed is a commonly used for reformatting text. grep, head are often good choice for simple tasks. But, jq and htmlq are specialized tools which worth testing for your developmental need. Both are similar tools, written in Rust and can be installed on Windows PC running Ubuntu Bash, Linux PC and MacOS X. For Mac, we will suggest to use Home Brew as package manager.
1 2 3 4 5 6 7 8 9 10 11 | # commands for Ubuntu/Debian sudo apt install cargo cargo install htmlq sudo apt install jq # commands for MacOS brew install rustup # installs cargo and rustc rustup-init rustc --version cargo install htmlq brew install jq |
Make your to add the suitable path to your .profile
file (what is profile file):
1 2 3 4 5 | # for sh, bash etc export PATH="$PATH:$HOME/.cargo/bin" # for the others setenv PATH $PATH:$HOME/.cargo/bin |
You can read the man page and also can try jq online:
---
1 | https://jqplay.org/ |
We can use echo and jq together:
1 | echo '[ {"value": "New", "onclick": "CreateNewDoc()"}, {"value": "Open", "onclick": "OpenDoc()"} ]' | jq '.[]' |
We can combine cURL and jq (this example is provided by Linode):
1 2 3 4 5 6 7 | curl 'https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/en.wikipedia/all-access/all-agents/Talking_Heads_discography/daily/20210928/20210930' | jq '.' </p;re> We can find all the links on our homepage using cURL and htmlq: <pre> curl -s https://thecustomizewindows.com | htmlq --attribute href a |
sed, grep, head etc tools have limitations. In common usage, they are the best tools and convenient to use in bash scripts. jq, htmlq are good for personal usage on local computer. These tools may also help you in IoT development.