I'm trying to swap words in each line using sed like so:
sed 's/\([^ ]*\), \([^ ]*\)/\2, \1/' sed.txt
And this is sed.txt:
FIRST LAST
FIRST LAST
FIRST LAST
FIRST LAST
But it's not working and I'm not sure why, my desired outcome is:
LAST FIRST
LAST FIRST
LAST FIRST
LAST FIRST
I know the example is insignificant but I'd like to understand sed more because I've only been using it for swapping words in their current position without changing positions.
sed -E 's/(.*) (.*)/\2 \1/' fileawk '{print $2, $1}'