How do I launch an editor from a shell script?

前端 未结 7 482
野性不改
野性不改 2021-02-04 03:44

I would like my tcsh script to launch an editor (e.g., vi, emacs):

#!/bin/tcsh
vi my_file

This starts up vi with my_file but first displays a w

7条回答
  •  面向向阳花
    2021-02-04 04:24

    Set your terminal tty to a variable, and then redirect the editor i/o through that variable.

    In your script:

    #!/bin/sh
    
    ls | while read a; do vi $a < $MYTTY >$MYTTY; done
    

    And then execute the script with:

    $ MYTTY=`tty` ./myscript >/tmp/log
    

提交回复
热议问题