Linux 基本指令 nano 和 cat

nano

nanolinux 的一款文字编辑工具.

nano执行t.py文件.

$ nano t.py

Linux 基本指令 nano 和 cat

然后按 “Ctrl + x” 来保存和退出.

cat

cat(catenate) 可以用来显示文件内容, 或者是将某个文件里的内容写入到其他文件里.

1 查看文件内容

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

2 > 将文件的内容放到另一个文件里

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

3 > 将多个文件的内容打包一起放入另一个文件

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

4 >> 将内容添加在一个文件末尾

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

Last updated

Was this helpful?