Linux Learning notes: Nano and Cat

Source: Internet
Author: User
Tags python script

learning content from Mo python:linux TutorialNano

nanois a text editing tool for Linux. We can use it to do the most basic terminal-end text editing, even write code ~ below we used to touch create a Python script. We can nano edit the text or script.

Then use nano this file to execute t.py .

$ nano t.py

He's going to be a text editor, and you can play some scripts in it, like me.

Then press "Ctrl + X" to save and exit. If you are prompted to save, you can click on the "Y" key and then enter and your file will be saved.

Then if you enter this in terminal, you can see that terminal executed your Python file.

$ python t.pyThis is a Python script!
Cat

cat(catenate) can be used to display the contents of a file, or to write the contents of a file into other files. Let us illustrate.

1 Viewing the contents of a file

$ cat t.pyprint("This is a Python script!")

2 > putting the contents of a file in another file

$ cat t.py > t1.py$ cat t1.pyprint("This is a Python script!")

3 > Package The contents of multiple files together into another file

For example, here we put the content in the t.py t1.py same time t2.py , if t2.py it is displayed, it has two lines "Print ...".

$ cat t.py t1.py > t2.py$ cat t2.pyprint("This is a Python script!")print("This is a Python script!")

4 >> Adding content to the end of a file

I created a t3 file that says "This is T3". Let's add this to the t2.py bar. The end of the content that will be >> added is t3 used t2.py .

$ cat t3 >> t2.py$ cat t2.pyprint("This is a Python script!")print("This is a Python script!")This is t3.

Linux Learning notes: Nano and Cat

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.