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- ...
随机推荐
- 每日一小练——高速Fibonacci数算法
上得厅堂,下得厨房,写得代码,翻得围墙,欢迎来到睿不可挡的每日一小练! 题目:高速Fibonacci数算法 内容:先说说Fibonacci数列,它的定义是数列:f1,f2....fn有例如以下规律: ...
- 敏捷开发-Scrum 真实
近期研究前 Scrum 数据编译的文件,在接下来的团队和项目开发.项目根据该引入 Scrum 一些练习,提高团队成员和项目之间的交付质量的合作. 参考资料: <轻松Scrum之旅-敏捷开发故事& ...
- OC -- 第一个类
OC -- 第一个类 类名:Car 属性:轮胎个数.时速 行为:跑 完整写一个类:类的声明和实现 1. 类的声明 代码: // NSObject 再Foundation框架中 #import & ...
- CRL 版本2.1.0.0下载
此次更新完善了部份功能,详情见UpdateLog,重新整理了开发文档,更美档,更详细 百度盘下载 下载地址: 百度盘下载
- python列表和QVariant
pyqt中.要给QAbstractTableModel的setData函数传递一个list參数: [20,'00:00:19'] 涉及到QVariant和list的转换. 能够使用QVariant类中 ...
- SE 2014年5月28日
R1模拟总部,R2 与R3模拟分部 如图配置 (1)网络中目前只有两站点, R1 和R2 .同时R2为动态获取IP地址一方,要求使用要求使用 GRE over IPSec VPN 野蛮模式,保证R1和 ...
- linux--文件夹下批量改动IP
sed -i 's/10.11/10.22/g' `grep ir 10.11 *| grep -E'.xml:|.cfg:|.ini:|.wsdl|.properties:' |awk -F:'{p ...
- 通过HttpURLConnection模拟post表单提交
通过HttpURLConnection模拟post表单提交 package junit; import java.io.InputStream; import java.net.HttpURLConn ...
- SAE开发一个应用(不仅仅是建站)
参考http://jingyan.baidu.com/user/npublic/?un=944615045 http://sae.sina.com.cn/ 激活sae账户 登陆新浪云计算官方网站,网址 ...
- linux操作提示:“Can't open file for writing”或“operation not permitted”的解决的方法
在linux上使用vi命令改动一个文件内容的时候,发现无法保存,每次写完使用":q!"命令能够正常退出可是使用":wq!"命令保存文件并退出时出现一下信息提示: ...