RH033读书笔记(7)-Lab 8 Introduction to String Processing
Lab 8 Introduction to String Processing
Sequence 1: Exercises in string processing
1. Other than the man page, how could you get a summary of options for the aspell command,
displayed one page at a time?
aspell --help | less
2. How many files are in the directory /usr/bin?
ls /usr/bin | wc -l
3. List the misspelled words in the /usr/share/doc/HTML/index.html file.
aspell list < /usr/share/doc/HTML/index.html
4. How many times does each misspelled word appear?
aspell list < /usr/share/doc/HTML/index.html | sort | uniq -c
5. Display the /etc/passwd line for any account that starts with the letter g
grep '^g' /etc/passwd
cat /etc/passwd | grep '^g'
6. Display the number of lines in /etc/passwd
wc -l /etc/passwd
cat /etc/passwd | wc -l
7. Display a list of usernames (and no other data) from /etc/passwd
cut -d: -f1 /etc/passwd
8. Display the /etc/passwd line for any account that is using the bash shell
grep 'bash$' /etc/passwd
9. Display the /etc/passwd line for any account that is not using the bash shell
grep -v 'bash$' /etc/passwd
10. Display a list of files in /etc/ that contain the word root. Display only the filenames and
do not print errors
grep -l root /etc/* 2> /dev/null
11. Display the shell being used by root, as stored in /etc/passwd.
grep '^root:' /etc/passwd | cut -d: -f7
Sequence 2: diff and patch
1. [student@stationX ~]$ cp /etc/issue ~/issue
2. vi ~/issue
Welcome to \n (\l)!
Red Hat Enterprise Linux Server release 5
Kernel \r on an \m
3. [student@stationX ~]$ diff /etc/issue ~/issue
4. [student@stationX ~]$ diff -u /etc/issue ~/issue > /tmp/issue.patch
5. [student@stationX ~]$ cat /tmp/issue.patch
+ represents a line that should be added
- represents a line that should be removed
6. [root@stationX ~]# patch -b /etc/issue /tmp/issue.patch
7. [student@stationX ~]$ diff -u /etc/issue ~/issue
8. [root@stationX ~]# restorecon /etc/issue
restore file(s) default SELinux security contexts.
9. [root@stationX ~]# patch -R /etc/issue /tmp/issue.patch
[root@stationX ~]# cp /etc.issue.org /etc/issue
Sequence 3: Stream editing with regular expressions
vi cats
cat
catalog
concatenate
polecat
Cat
1. sed 's/cat/dog/' cats
dog
dogalog
condogenate
poledog
Cat
2. sed 's/^[Cc]at/dog/' cats
dog
dogalog
concatenate
polecat
dog
3. sed 's/^cat$/dog/i' cats
dog
catalog
concatenate
polecat
dog
[student@stationX ~]$ sed '10,35s/cat/dog/' pets
[student@stationX ~]$ sed '/digby/,/duncan/s/cat/dog/' pets
[student@stationX ~]$ sed -e 's/cat/dog/g' -e 's/cow/goat/g' pets
vi myedits
s/cat/dog/g
s/cow/goat/g
[student@stationX ~]$ sed -f myedits pets
RH033读书笔记(7)-Lab 8 Introduction to String Processing的更多相关文章
- RH033读书笔记(15)-Lab 16 The Linux Filesystem
Lab 16 The Linux Filesystem Goal: Develop a better understanding of Linux filesystem essentials incl ...
- RH033读书笔记(2)-Lab 3 Getting Help with Commands
Lab 3 Getting Help with Commands Sequence 1: Using the Help Tools 1. man -f keyword whatis keyword l ...
- RH033读书笔记(5)-Lab 6 Exploring the Bash Shell
Lab 6 Exploring the Bash Shell Sequence 1: Directory and file organization 1. Log in as user student ...
- RH033读书笔记(4)-Lab 5 File Permissions
Lab 5 File Permissions Sequence 1: Determining File Permissions 1. What is the symbolic representati ...
- RH033读书笔记(3)-Lab 4 Browsing the Filesystem
Lab 4 Browsing the Filesystem Sequence 1: Directory and File Organization 1. Log in as user student ...
- RH033读书笔记(6)-Lab 7 Standard I/O and Pipes
Lab 7 Standard I/O and Pipes 1. [student@stationX ~]$ cat /proc/cpuinfo /proc/meminfo 2. [student@st ...
- RH033读书笔记(8)-Lab 9 Using vim
Lab 9 Using vim Sequence 1: Navigating with vim 1. Log in as user student 2. [student@stationX ~]$ c ...
- RH033读书笔记(10)-Lab 11 Process Control
Lab 11 Process Control Sequence 1: Job Control 1. [student@stationX ~]$ su - 2. Begin some jobs in t ...
- RH033读书笔记(9)-Lab 10 Understanding the Configuration Tools
Lab 10 Understanding the Configuration Tools Sequence 1: Configuring the Network with system-config- ...
随机推荐
- hdu1495之经典搜索
非常可乐 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submi ...
- HLG 2163 方格取数 (最大网络流)
题目链接: m=ProblemSet&a=showProblem&problem_id=2163">点击打开链接 Description : 给你一个n*n的格子的棋 ...
- 201215-03-19---cocos2dx内存管理--具体解释
因为cocos2dx我们的使用c++写的,所以内存管理就是一个绕只是去的坎,这个你不懂内存仅仅懂业务逻辑的话,还玩什么c++,今天看了半天这个东西,事实上本质上是理解的,可是就是有一个过不去的坎,最终 ...
- C++ 多态性分析
编译 - 时间多态性--函数重载 编译后的中间代码(例如GCC产生.o文件.此时还不是汇编语言)函数名字有变化,看以下两个样例. void cc_show(const char*str) -& ...
- mysql登录报错 ERROR 1045 (28000)
1.现象: [root@localhost ~]# mysql -u root -p Enter password: ERROR 1045 (28000): Access denied for us ...
- SQL简单的日报和月报
--320, SQL SERVER 日报 --查询2009-01-01当天客户A1,A2,A3的订单数量 SELECT Cust_Name , CONVERT(CHAR(10), Order_Date ...
- Egret是一套完整的HTML5游戏开发解决方案
Egret是一套完整的HTML5游戏开发解决方案.Egret中包含多个工具以及项目.Egret Engine是一个基于TypeScript语言开发的HTML5游戏引擎,该项目在BSD许可证下发布.使用 ...
- XML,Object,Json分析转换Xstream采用
XML,Object,Json转换之浅析Xstream的使用 请尊重他人的劳动成果,转载请注明出处:XML,Object,Json转换之浅析Xstream的使用 XStream的是一个简单的库.主要用 ...
- sql大小转换函数
将字段值转换成大写 UPDATE t SET [name]=UPPER([name]) 将字段值转换成小写 UPDATE t SET [name]=LOWER([name])
- Swift的属性,方法,下标脚本以及继承
从这篇章节起,Swift编程语言指南大部分的重要内容在于概念,代码并非太多.理解Swift的面向对象理念,语法以及类结构,构造析构过程对于非常好的应用Swift语言将会有比較大的帮助. 属性 存储属性 ...