Is there any way to pipe echo output to another echo and slice it without using variable?
For example: This can be done without using pipe
var="heyyy hello there HRU?"
echo "${var:11}"
But we don't use var while using pipe...
echo "heyyy hello there HRU?" | echo "${?:11}"
How to capture the output from previous command and slice it as we use do using variable? Is there any way to do it?
I know it can be done using multiple commands like "sed", "awk", "cut", etc., but I just wanted to know if there any way to do it with echo.
Capture it in a variable.
echo "heyyy hello there HRU?" | { var=$(cat); echo "${var:11}"; }
echo doesn't use stdin !. It can just print arguments given to it. So what you're trying won't work in short.
echo -- write arguments to the standard output
Refer Man Page : https://man7.org/linux/man-pages/man1/echo.1p.html
STDIN
Not used.
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