0

I want to achieve something quite simple with pipeline:

step 1 : cat input1 input2 > output

step 2 : gedit output

I can do

cat input1 input2 > output | gedit output

But I wonder how can I ommit typing the name of output file in this case? So the file created from cat redirect should be the file gedit open. Thanks!

Arch1tect
  • 4,128
  • 10
  • 48
  • 69

2 Answers2

1

Just define a bash function for your purpose (perhaps in your ~/.bashrc if you want to make it permanent), e.g.

 editcat() {
   cat $* > output
   gedit output
 }

You might want to make that function more fancy, by generating the output file as a temporary file using mktemp(1)

 editcat() {
   local editemp=$(mktemp)
   cat $* > $editemp
   gedit $editemp
   rm $editemp
 }

But you might consider just using less(1)

Basile Starynkevitch
  • 223,805
  • 18
  • 296
  • 547
0

You can try

gedit <(cat file1 file2)

or

cat input1 input2 | gedit 
ghostdog74
  • 327,991
  • 56
  • 259
  • 343