Is there are way to use STDIN in a bash function?
e.g.
# echo "somevar = (100)" >> test.txt
# grep -Eo "\([[:digit:]]+\)$" test.txt
(100)
So that's fine I've got my number, next I want to remove the brackets. What I did was:
string=`grep -Eo "\([[:digit:]]+\)$" test.txt`; echo ${string:1:-1}
100
So my problem was solved, but what I spent a long time doing was:
grep -Eo "\([[:digit:]]+\)$" test.txt | echo ${$1:1:-1}
grep -Eo "\([[:digit:]]+\)$" test.txt | ${$1:1:-1}
grep -Eo "\([[:digit:]]+\)$" test.txt | xargs echo ${:1:-1}
grep -Eo "\([[:digit:]]+\)$" test.txt | xargs -I 's' echo ${s:1:-1}
etc, etc ... none of which work.
So assuming it is possible, how do I use the piped in value in the bash command?