I have a text in an email on a windows box that looks something like this:
100 some random text
101 some more random text
102 lots of random text, all different
103 lots of random text, all the same
I want to extract the numbers, i.e. the first word on each line. I've got a terminal running bash open on my Linux box...
If these were in a text file, I would do this:
awk '{print $1}' mytextfile.txt
I would like to paste these in, and get my numbers out, without creating a temp file.
my naive first attempt looked like this:
$ awk '{print $1}'
100 some random text
100
101 some more random text
101
102 lots of random text, all different
103 lots of random text, all the same
102
103
The buffering of stdin and stdout make a hash of this. I wouldn't mind if stdin all printed first, followed by all of stdout; this is what would happen if I were to paste into 'sort' for example, but awk and sed are a different story.
a little more thought gave me this:
open two terminals. Create a fifo file. Read from the fifo on one terminal, write to it on another.
This does in fact work, but I'm lazy. I don't want to open a second terminal. Is there a way in the shell that I can hide the text echoed to the screen when I'm passing it in to a pipe, so that I paste this:
100 some random text
101 some more random text
102 lots of random text, all different
103 lots of random text, all the same
but see this?
$ awk '{print $1}'
100
101
102
103