I have a pipe-delimited text file containing about 900 rows of data. Each row contains a set of numbers with a username at the end. e.g.
2792|5750|125|4.0|0.25|||6|2|user1
2802|6000|126|4.0|0.25|||2|3|user2
2801|6000|125|4.0|0.25|||4|4|user2
2805|5500|125|4.5|0.25|||3|2|user1
2805|6250|122|4.5|0.25|||4|7|user3
2811|4750|125|3.0|0.25|||4|2|user1
2828|5750|121|4.0|0.25|||6|2|user2
What I would like to do is create three new files: one for each of the users, containing only their data. (e.g. the file for user1 would contain only the first, fourth, and sixth line of the original file). Should I use awk or sed to do this?
One way:
Here’s the results of
grep . user*:Also, some people like to add a file extension. This can be done like: