Reputation: 10228
Right now I have
echo 'abcdef' | gzip | wc -c
What I would like to have is
$(| gzip | wc -c) ???mystery-pipe-operator??? echo 'abcdef'
or
$(gzip | wc -c) <(echo 'abcdef')
But neither of them work, of course, because I don't know what I'm doing. I want to restructure the echo to the end so that I can edit the string easily when I press up and down to navigate my command-line history. I'm using zsh. I know about Ctrl-R to do a reverse incremental search, but it's too much of a hassle.
Thanks!
Upvotes: 0
Views: 598
Reputation: 4385
In zsh (and also in bash) you can use a compound command together with process substitution:
{ gzip | wc -c; } < <(echo abcdef)
or even with a "here string":
{ gzip | wc -c; } <<<abcdef
Upvotes: 1
Reputation: 212248
It is probably easier to do:
$ s=abcdef
$ echo "$s" | gzip | wc -c
and then redefine s
before repeating the command from your history. Or use a function:
$ foo() { echo "$*" | gzip | wc -c; }
$ foo abcdef
Upvotes: 1