From 7f8aef4d417e427153caba4255a2282cb9dd30d9 Mon Sep 17 00:00:00 2001 From: Johannes Stoelp Date: Fri, 5 Apr 2024 22:43:27 +0200 Subject: bash: printf -v --- src/tools/bash.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/tools/bash.md b/src/tools/bash.md index e12d8c0..f27b3a2 100644 --- a/src/tools/bash.md +++ b/src/tools/bash.md @@ -41,6 +41,11 @@ ${foo/pattern/string} # replace pattern with string when expanding foo # '/' replace all occurences of pattern # '#' pattern match at beginning # '%' pattern match at end + +# set programmatically with priintf builtin +printf -v "VAR1" "abc" +NAME=VAR2 +printf -v "$NAME" "%s" "def" ``` > Note: `prefix`/`suffix`/`pattern` are expanded as [pathnames](#pathname). -- cgit v1.2.3