You can use Here Strings. It is supported by bash
, zsh
and other common shells.
Example: The grep
command only work with files but here we are passing a variable using Here Strings to be searched for pattern by grep
.
$ str="this is a test line"
$ grep -o "test" <<< "$str"
test
As far as your command is concerned you can use:
$ base64 <<< "$str"