Reputation: 623
I'm having issues to use the output of a pipe such as
ls *.gz | wc -l / 2 | bc
immidiately as input to a shell calculator tool such as bc
. I'm not sure how to put the quotation marks or if this is possible at all without assigning a variable?
The background is that in the folder each two files belong together, so I simply want to divide the total number of files by 2.
There might be an obvious solution but I could not find it so far...
I'm using bash
if that is important?
Upvotes: 1
Views: 1524
Reputation: 11047
As mentioned by Charles that parsing ls
is not a good practice but anyway if you want to do that, you can try
ls *.gz |wc -l | xargs echo "0.5*" | bc
Upvotes: 2