I want to move lines matching certain pattern from file1 to file2. Analogous to operation cut and paste from one file to another in windows
You can put a &&
between the two commands to make them a single line. But that won't be more readable, so I don't recommend you do that.
To do the same in one command, you would need something that can edit a file in-place, removing lines you don't want and at the same time printing those lines to stdout
or stderr
so you could redirect it to the other file.
Maybe ed
can do this but I don't know how to write that.
I don't think there is another "standard" UNIX tool to do this.
Btw, cut & paste actually has 3 steps:
The 2-step UNIX command does it without a clipboard.