linux下文本操作命令(大数据学习第四天)

Linux文本操作命令

cat 查看文件内容

cat filename                   
cat file1
cat  file1 file2 > file3      //合并file1 file2 到file3

more 分屏显示文件内容

more filename 
cat filename |more    //一个效果 空格查看下一页

head -n 5 filename //查看前5行 查看前N行

tall -n 5 filename 查看最后5行 查看最后N行

stat 查看文件详细信息 stat filename

echo

输出文件内容 echo filename 
echo sdfsdf>filename  将sdfsd写入filename中 如果没有filename将会自动创建filename   

在这里插入图片描述
在这里插入图片描述

>

管道重定向至文件,覆盖模式。eg: echo "ww">aa
file1 >file2   //file1内容将会覆盖file2
cat file1 file2 > file3 //file1 file2 覆盖file3

>>

管道重定向至文件,追加模式。
file1 >file2   //file1内容将会添加到file2 file2 原有内容还在
cat file1 file2 > file3 //file1 file2 添加file3 原有内容还在

Linux 搜索命令

grep

文 本 内 容 搜 索 。 - i 忽 略 大 小 写 - n 显 示 匹 配 行 

在这里插入图片描述

	在cat 输出file3的文本中搜索as

find

find <path> <options> find /-namex * 
find / -size +1000k|m find  /  -amin -10   # 查找系统中最后10分钟访问的文件 
find ./ -empty  搜索空文件夹
find . -maxdepth 5 //搜索文件深度为5层
find . -regex ".*\.\(txt\|c\)

which

查询程序的存储位置,只会命中一次

whereis

whereis ls      查询ls的存储位置 -b      只搜索二进制文

Linux 正则表达式应用

Linux 正则表达式应用: 
find -name 仅匹配文件名 
find -regex 匹配的是全文件名(含路径) 
如匹配当前目录的abc文件,应用为./abc
查找大文件 •find . -type f -size +800
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值