I have a file, one of whose line contains:
number 8
how can i use sed, grep or whatever linux script to find out what integer is there in front of the line that starts with "number"?
Thanks...
I have a file, one of whose line contains:
number 8
how can i use sed, grep or whatever linux script to find out what integer is there in front of the line that starts with "number"?
Thanks...
use grep and cut, this will return only the number
cat ./file.txt | grep number | cut -d " " -f 2
Another way is to use awk
:
awk '/number/ {print $2}' < ./file.txt
It's a single command, which some prefer. If it's a large file, you may prefer the cat | grep | cut
-way, as the three programs run in separate processes.