I currently have 2 bash command line strings I use to gather data needed for a certain task. I was trying to simplify and have only one command used to gather the data without using a script.First I cat a file and pipe into a grep command and only display the integer value. I then copy and paste that value into an equation which will always be constant except for the grepped value from the first command.1st command:  cat /proc/zem0 |grep -i isrs|grep -Eo '[0-9]+$'2nd command:  echo $(( (2147483633-**grep value**)/5184000 ))I'm stumped as to how I can accomplish this. Any guidance on this would be greatly appreciated!
Using the output of `grep` as variable in second command
bash;command line;variable;output
Here it is as one command:echo $(( (2147483633 - $(grep -i isrs /proc/zem0 | grep -Eo '[0-9]+$') )/5184000 ))How the simplification was doneFirst consider this pipeline:cat /proc/zem0 |grep -i isrs`This can be simplified to:grep -i isrs /proc/zem0Thus, the whole of the first command becomes:grep -i isrs /proc/zem0 | grep -Eo '[0-9]+$'The last change is to substitute the first command into the second using command substitution: $(...).   Thus, we  replace:echo $(( (2147483633-**grep value**)/5184000 ))with:echo $(( (2147483633-$(grep -i isrs /proc/zem0 | grep -Eo '[0-9]+$'))/5184000 ))One more simplificationIf your grep supports perl-style regular expressions, such as GNU grep, then, as suggested by jimmij in the comments, one more simplification is possible:echo $(( (2147483633-$(grep -Pio 'isrs.*?\K[0-9]+$' /proc/zem0))/5184000 ))