echo 20220506 | cut -c5-6
gives the output as
05
I want add a '/' at the end of the output(05/). Can someone kindly help?
CodePudding user response:
Try
echo 20220506 | cut -c5-6 | sed 's/$/\//'
Sed is stream editor and s/$/\//
means
s : substitute
$ : end of line
\/ : / escaped with \
other slashes (/) : separator character of parameters to substitution operator.
CodePudding user response:
Instead of using a pipe |
character, you could use backticks to evaluate your command inside another command.
echo `echo 20220506 | cut -c5-6`/
> 05/