So I'm trying to make a sh script where I put a value that I get from a command, into a variable, in this case n, but I have no idea what I'm doing, and this here obviously doesn't work lol:
1 n=0
2 cat test | grep -cE '[0-9]{1,4}' > $n
3 echo "there were $n lines in test" > rtest1
It makes a rtest1 file which says "there were 0 lines in test"
Test is a file that has 10 lines, by the way.
So how does one assign a value from stdout to a variable in shell scripting? :D
file=./test– nohillside Aug 09 '18 at 20:09