> For the complete documentation index, see [llms.txt](https://baozoulin.gitbook.io/linux/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://baozoulin.gitbook.io/linux/he-wen-jian-da-jiao-dao/linux-ji-benzhi-ling-nano-he-cat.md).

# Linux 基本指令 nano 和 cat

## nano

**nano**是 **linux** 的一款文字编辑工具.

用**nano**执行**t.py**文件.

```python
$ nano t.py
```

[\
![Linux 基本指令 nano 和 cat](https://morvanzhou.github.io/static/results/linux-basic/02-04-02.png)](https://morvanzhou.github.io/static/results/linux-basic/02-04-02.png)

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

## cat

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

1 查看文件内容

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

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

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

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

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

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

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