View Single Post
Old 2020-05-27, 09:07   #369
axn
 
axn's Avatar
 
Jun 2003

4,637 Posts
Default

Quote:
Originally Posted by kruoli View Post
Unfortunately, that does not invert the order in a line. I'd propose:
Code:
grep has results.txt | cut -d' ' -f3,7 | sort | uniq | sed 's/^\([^ ][^ ]*\) \([^ ][^ ]*\)/\2 | \1/'
(I'd be using the "c" tag but that gave weird formatting, how can I escape square brackets?)

The result seems a bit chaotic, because the first column has no constant size. One could solve that using e.g. xargs and printf.
This works! I managed to simplify a bit (got rid of beginning of line ^, and aa* became a+, [^ ] replaced with just .):
Code:
grep has results.txt | cut -d' ' -f3,7 | sort | uniq | sed 's/\(.\+\) \(.\+\)/\2 | \1/'

Last fiddled with by axn on 2020-05-27 at 09:08
axn is online now   Reply With Quote