Reputation: 9837
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...
Upvotes: 0
Views: 689
Reputation: 6108
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.
Upvotes: 1
Reputation: 2218
use grep and cut, this will return only the number
cat ./file.txt | grep number | cut -d " " -f 2
Upvotes: 1