echo Hello World | nano - | less
I want to modify Hello -> Goodbye while in the the text editor.
It does not have to be with nano.
I am stuck with nano reading stdin but requiring me to write to a file (writing to – creates a file named -)
bashbufferstdinstdout
echo Hello World | nano - | less
I want to modify Hello -> Goodbye while in the the text editor.
It does not have to be with nano.
I am stuck with nano reading stdin but requiring me to write to a file (writing to – creates a file named -)
Best Answer
The moreutils package has a great command for doing this, called
vipe
. From the man page:By default this will use the
editor
command, which is usually just a symlink to the default command line editor. You can change this by either altering the link (useupdate-alternatives
on Debian based systems) or using theEDITOR
environmental variable. Eg, you could do:Otherwise, if the particular text editor doesn't have support for this kind of thing, I think you are stuck with manually creating a temporary file, writing the file to that, running the editor, inputting the file to the rest of the pipeline and removing the temporary file. The
vipe
command basically takes care of all this. This is nice, but the command is rarely available by default.