`

7.2 Linux 命令行文本处理

 
阅读更多
1.基于关键字搜索
syntax:grep [paramter] "keywords" filepath
[paramter]: -i  ignore upper or lower case
-n  show the located row number
-v  show the row which not contain the "keywords"
-Ax show specific number of rows after the "keywords" located row
-Bx show specific number of rows after the "keywords" located row
eg: find / -user msdomain1\pzhou | grep 'keywords
    grep -B3  "peter"  /date/file


2. cut基于列处理文本
syntax: cut [paramter] file
paramter: -d    point out he seperate words (default tab)
  -f    point out the numver of column which will be output
  -c    cut rows by index of character in each row
eg: cut -c2-6 /etc/passwrod   show form 2 to 6 character of each row
cut -d: -f1 /ect/passwd


3. wc statistic infor of text
syntax: cut [params] file
params: -l    number of rows
-w    number of words
-c    number of byte
-m    number of character


4.sort text
syntax: sort [params] file
params: -r   order by desc
-n   sort by number
-f   ingore upper or lower case
-u   delete duplicated row


5.uniq  delete duplicated labour rows
syntax: uniq file


6. compare two file
syntax: diff [param] file1 file2
params: -i ignore upper or lower case
-b ignore blank
-u make a output more uniform(use to make patch file)


7.check spell
syntax: aspell file


8.tranfer file
syntax: tr [params] < filepath
params: -d 'words' delete all 'words'
'a-z' 'A-Z'  switch from lower case to upper case


9 replace workds
syntax: sed
eg:  sed 's/word1/word2/g' file       search(s) and replease all(globally g) word1 to replace word2
sed '1,50s/word1/word2/g' file   search and replace for  row 1to50
sed  -e  's/word1/word2/g' -e 's/word3/word4/g' file          iterate replace condition
sed -f conditionfilename file       release replace condition from file

分享到:
评论

相关推荐

    边干边学Linux__第二版_doc格式

    7.2 编C语言程序 7.3 make工具 7.4 gdb调试工具 第8章 Bourn Again Shell编程 8.1 bash脚本的建立和运行 8.2 shell的变量 8.3 shell脚本位置参数的传递 8.4 控制结构语句 8.5 其他几个有用的语句 8.6 数值处理 8.7 ...

    linux操作系统命令大全

    使用命令行进行管理是Linux系统的特点,对于Windows用户来说,需要尽快适应这种操作方式。  了解了命令的功能之后,还需要通过实践来掌握这些命令的使用方法,因为它们是进行系统管理的基础。 ·2.1 Linux的DOS-...

    LINUX安装与配置简明手册

    7.2 快速解决方案 88 7.2.1 查找窗口管理器程序 88 7.2.2 在Gnome桌面环境中运行程序 88 7.2.3 在Gnome桌面环境中隐藏任务条 89 7.2.4 使用Gnome桌面环境中的帮助系统 89 7.2.5 使用Gnome桌面环境中的控制面板 90 ...

    LINUX 24学时教程

    本书详细讲解了用Linux的图形配置工具配置Caldera OpenLinux,通过一个ppp与网络连接、使用K桌面环境、用StarOffice提高在家办公的效率、网络浏览、发传真、接收email及使用GIMP等图形工具。 24学时每次1小时的课程...

    RED HAT LINUX 6大全

    7.2 SMTP和sendmail 106 7.2.1 Internet邮件协议 106 7.2.2 域名系统和电子邮件 107 7.2.3 sendmail的工作 110 7.2.4 sendmail的辅助文件 111 7.2.5 别名文件 111 7.2.6 设置sendmail 112 7.2.7 sendmail.cf:配置...

    LINUX与UNIX SHELL编程指南(很全)

    7.2 在行首以^匹配字符串或字符序列 50 7.3 在行尾以$匹配字符串或字符 51 7.4 使用*匹配字符串中的单字符或其重复 序列 51 7.5 使用\屏蔽一个特殊字符的含义 52 7.6 使用[]匹配一个范围或集合 52 7.7 使用\{\}匹配...

    Linux管理员指南

    此相对独立 4 1.3.3 Windows中的“网络邻居”概念 5 1.3.4 Windows中的注册表文件与文本文 件的比较 6 1.3.5 域的概念 6 1.4 小结 7 第2章 按服务器配置安装Linux 8 2.1 安装之前 8 2.1.1 ...

    redhat linux教材20课程学习文档

    16.2.2 通过命令行管理打印机 16.2.3 通过web界面管理打印机 16.3 使用CUPS打印 16.3.1 打印文件 16.3.2 选择打印机 16.3.3 标准打印选项 第十七章 基本网络配置与管理 17.1 网络环境概述 17.1.1 使用ADSL连接 ...

    Linux与unix shell编程指南

    7.2 在行首以^匹配字符串或字符序列 50 7.3 在行尾以$匹配字符串或字符 51 7.4 使用*匹配字符串中的单字符或其重复 序列 51 7.5 使用\屏蔽一个特殊字符的含义 52 7.6 使用[]匹配一个范围或集合 52 7.7 使用\{\}匹配...

    Linux shell编程指南

    7.2 在行首以^匹配字符串或字符序列 50 7.3 在行尾以$匹配字符串或字符 51 7.4 使用*匹配字符串中的单字符或其重复 序列 51 7.5 使用\屏蔽一个特殊字符的含义 52 7.6 使用[]匹配一个范围或集合 52 7.7 使用\{\}匹配...

    linux安装与配置简明手册

    7.2 快速解决方案 88 7.2.1 查找窗口管理器程序 88 7.2.2 在Gnome桌面环境中运行程序 88 7.2.3 在Gnome桌面环境中隐藏任务条 89 7.2.4 使用Gnome桌面环境中的帮助系统 89 7.2.5 使用Gnome桌面环境中的控制面板 ...

    绝版经典《Linux与UNIX Shell编程指南》

    7.2 在行首以^匹配字符串或字符序列 50 7.3 在行尾以$匹配字符串或字符 51 7.4 使用*匹配字符串中的单字符或其重复 序列 51 7.5 使用\屏蔽一个特殊字符的含义 52 7.6 使用[]匹配一个范围或集合 52 7.7 使用\{\}匹配...

    Shell脚本学习笔记

    第1章 BashShell命令 6 1.1 Shell提示符 6 1.2 文件与目录Shell命令 7 1.2.1 更改目录命令(cd) 7 1.2.2 列表命令(ls) 7 1.2.3 操作文件命令 10 1.2.4 目录处理命令 14 ...7.3.4 插入和附加文本 129

    LINUX与UNIX SHELL编程指南 高清PDF

    7.2 在行首以^匹配字符串或字符序列 50 7.3 在行尾以$匹配字符串或字符 51 7.4 使用*匹配字符串中的单字符或其重复 序列 51 7.5 使用\屏蔽一个特殊字符的含义 52 7.6 使用[]匹配一个范围或集合 52 7.7 使用\{\}匹配...

    linux shell 编程教程

    linux shell编程 教程大全 目 录 译者序 前言 第一部分 shell 第1章 文件安全与权限 1 1.1 文件 1 1.2 文件类型 2 1.3 权限 2 1.4 改变权限位 4 1.4.1 符号模式 4 1.4.2 chmod命令举例 5 1.4.3 绝对模式 5 1.4.4 ...

    CentOS.5系统管理-part1

    3.5 文本处理命令 3.6 信息显示命令 3.7 基本网络操作命令 第4章 Linux字符界面操作进阶 4.1 提高工作效率 4.1.1 命令行补全 4.1.2 命令历史 4.1.3 命令别名 4.2 重定向和管道 4.2.1 重定向 4.2.2 管道 4.3 文件权限...

Global site tag (gtag.js) - Google Analytics