How can I create and open a file from terminal with a single command?

后端 未结 8 1292
野性不改
野性不改 2020-12-24 06:56

To create a file from terminal I type the following...

$ touch filename.py

To open the file I just created from terminal, I then type...

8条回答
  •  [愿得一人]
    2020-12-24 07:33

    you can use:

    cat > youNewFile.someExtension
    

    Example:

    cat > myNewFile.txt
    

    After you are done press Ctrl + d to save or Ctrl + c to abort (but in this case it's gonna save an empty file. The redirection operator ( > ) will create the file if it doesn't already exists in your folder and you will be able to edit it right a way through the terminal.

提交回复
热议问题