How to make this Through command work with stdin?

11 views
Skip to first unread message

jason404

unread,
Jul 28, 2021, 10:54:51 AM7/28/21
to niceeditor
This is more of a bash question that ne specific, but when I ask on IRC I get asked what I am trying to do, which complicates things.

I just wanted to make a quick command which would sort words on a single line and i came up with this:

    $ echo "some words to sort" | xargs -n 1 | sort | xargs

But I can't figure out how to make this work with stdin as input so that I can make it work with Through, like I have done with sed commands.

Any ideas?


todd_...@unc.edu

unread,
Jul 28, 2021, 12:26:30 PM7/28/21
to niceeditor
Mark the beginning of the line, move down to the beginning of the next line, then on the command line enter

   through    xargs -n 1 | sort | xargs

That works for me. I note that regardless of whether you include the end-of-line in your selection, you'll always get a trailing new-line. So if you only select an inner portion of a line, the line will be broken after the through command returns. But if you're making a macro, you can account for that.

jason404

unread,
Jul 29, 2021, 9:22:25 AM7/29/21
to niceeditor
Thanks Todd.
Reply all
Reply to author
Forward
0 new messages