[Linux 新手出航 1-7] Windows 上执行 Ubuntu - 测试基本参数5 ( cat ,grep)

目的


这篇主要讲解一些基础的指令,大致上预计要讲的是
12. cat 指令
13. grep 指令

开头依样是在 c槽的 Linux_test 资料夹里面测试
输入指令: cd /mnt/c/Linux_test

cd /mnt/c/Linux_test

http://img2.58codes.com/2024/20135862u0lUKQmdhI.png

Linux_test 资料夹内有两个东西 test1 、 test2

http://img2.58codes.com/2024/20135862r699MrwV98.png


cat 指令


在测试 cat 前
用记事本将 test1 写上 "Try the cat order"
用记事本将 test2 写上 "new information"

http://img2.58codes.com/2024/20135862cHvynygLbS.png


cat 的功能用 Help 来看

输入指令: cat --help

cat  --help
Usage: cat [OPTION]... [FILE]...Concatenate FILE(s) to standard output.With no FILE, or when FILE is -, read standard input.

功能
简单来讲就是显示文件内容

显示文件内容显示多个文件内容,并组合起来

用法
用法有一种

cat 文件1 文件2 ..........

测试指令
看看 test1 的内容

输入指令: cat test1
/mnt/c/Linux_test$ cat test1Try the cat order

看看 test1 test2 的内容

输入指令: cat test1 test2
/mnt/c/Linux_test$ cat test1 test2Try the cat ordernew information

http://img2.58codes.com/2024/20135862MCGaKwgWrM.png



grep 指令


在测试 grep 前
用记事本将 test1 写上 "Try the cat order"
用记事本将 test2 写上 "new information"

http://img2.58codes.com/2024/201358629bLV0JGhd7.png


grep 的功能用 Help 来看

输入指令: grep --help

grep  --help
Usage: grep [OPTION]... PATTERN [FILE]...Search for PATTERN in each FILE.

功能
简单来讲就探索文件内容 是否有指定的字串


用法
用法有一种

grep 探索字串 文件1 文件2 ..........
grep 探索字串 文件1  文件2   ..........

测试指令
test1 内容为 "Try the cat order"
test2 内容为 "new information"

在 test1 和 test2 内探索字串 "or"
输入指令: grep or test1 test2
grep or test1 test2

http://img2.58codes.com/2024/20135862QM6Q3n86eB.png


在 test1 和 test2 内探索字串 "Try"
输入指令: grep Try test1 test2
grep Try test1 test2

http://img2.58codes.com/2024/20135862aMqMqooxtr.png


大致上 入门指令就到这里 谢谢看到这里。

Vim 的东西待补


关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章