You can use $(!!) to recompute (not re-use) the output of the last command. The !! on its own executes the last command.
$_ (dollar underscore) is another special bash parameter and used to reference the absolute file name of the shell or bash script which is being executed as specified in the argument list. This bash parameter is also used to hold the name of mail file while checking emails. $@
How can I set a variable to the output of a command in Bash? You need to use command substitution feature of bash. It allows you to run a shell command and store its output to a bash variable.
The echo command is one of the most commonly and widely used built-in commands for Linux bash and C shells, that typically used in a scripting language and batch files to display a line of text/string on standard output or a file.
In bash, is there a way to echo/print the last stdout? Is there a variable that stdout is assigned to?
I don't want to redirect the output. I just want to be able to read/print it after a command is run.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With