Dasel is a tool for selecting and modifying data which presented in different formats. Dasel supports JSON, TOML, YAML, XML and CSV data formats. This tool supports conversion between formats.
This tutorial shows how to install Dasel on Ubuntu 24.04.
Install Dasel
Download executable file from releases page of the Dasel repository.
sudo wget -qO /usr/local/bin/dasel https://github.com/TomWright/dasel/releases/latest/download/dasel_linux_amd64
Set execute permission for a file:
sudo chmod a+x /usr/local/bin/dasel
We can check Dasel version:
dasel --version
Testing Dasel
Create test.json
file for testing:
echo '{"status":"success","data":[{"name":"John","age":25},{"name":"James","age":29}]}' > test.json
Dasel use the same selector syntax no matter the data format. Each different part in selector is separated by a dot (.
). For example, the following command selects all elements and prints nicely formatted JSON:
dasel -s '.' -f test.json
The output of the command:
{
"data": [
{
"age": 25,
"name": "John"
},
{
"age": 29,
"name": "James"
}
],
"status": "success"
}
We can select a particular field as follows:
dasel -s '.data.[1].name' -f test.json
Output:
"James"
Dasel can convert one data format to another. For example, the following command converts JSON to YAML:
dasel -f test.json -w yaml > test.yaml
Uninstall Dasel
If you want to completely remove Dasel, delete related file:
sudo rm -rf /usr/local/bin/dasel
Leave a Comment
Cancel reply