mirror of
https://gitea.com/mcereda/oam.git
synced 2026-02-20 02:24:25 +00:00
Improved SED commands
This commit is contained in:
@@ -4,11 +4,19 @@
|
||||
|
||||
```sh
|
||||
# Delete lines matching "OAM" from a file.
|
||||
sed -e '/OAM/d' -i .bash_history
|
||||
# Overwrite the source file with the changes.
|
||||
sed '/OAM/d' -i .bash_history
|
||||
|
||||
# Change fstab entries.
|
||||
# Show changed fstab entries.
|
||||
# Don't save the changes.
|
||||
sed /etc/fstab \
|
||||
-e "s|#.*\s*/boot\s*.*|/dev/sda1 /boot vfat defaults 0 0|" \
|
||||
-e "s|#.*\s*ext4\s*.*|/dev/sda2 / btrfs compress-force=zstd 0 0|" \
|
||||
-e '/#.*\s*swap\s*.*/d'
|
||||
```
|
||||
|
||||
## Further readings
|
||||
|
||||
- [GNU SED Online Tester]
|
||||
|
||||
[gnu sed online tester]: https://sed.js.org/
|
||||
|
||||
@@ -164,14 +164,26 @@ resource "azurerm_key_vault_key" "key" {
|
||||
}
|
||||
```
|
||||
|
||||
### Export the contents of a tfvars file as shell variables
|
||||
|
||||
```sh
|
||||
# As normal shell variables.
|
||||
eval "export $(sed -E 's/[[:blank:]]*//g' file.tfvars)"
|
||||
|
||||
# As TF shell variables (TF_VAR_*).
|
||||
eval "export $(sed -E 's/([[:graph:]]+)[[:blank:]]*=[[:blank:]]*([[:graph:]]+)/TF_VAR_\1=\2/' file.tfvars)"
|
||||
```
|
||||
|
||||
## Further readings
|
||||
|
||||
- [CLI Documentation]
|
||||
- [Providers best practices]
|
||||
- [Version constraints]
|
||||
- [References to Named Values]
|
||||
- [Environment Variables]
|
||||
|
||||
[cli documentation]: https://www.terraform.io/docs/cli/
|
||||
[environment variables]: https://www.terraform.io/cli/config/environment-variables
|
||||
[providers best practices]: https://www.terraform.io/language/providers/requirements#best-practices-for-provider-versions
|
||||
[references to named values]: https://www.terraform.io/language/expressions/references
|
||||
[version constraints]: https://www.terraform.io/language/expressions/version-constraints
|
||||
|
||||
Reference in New Issue
Block a user