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- ...
随机推荐
- A Game of Thrones(15) - Sansa
Eddard Stark had left before dawn, Septa Mordane informed Sansa as they broke their fast. “The king ...
- poj3177(边双连通分量+缩点)
传送门:Redundant Paths 题意:有n个牧场,Bessie 要从一个牧场到另一个牧场,要求至少要有2条独立的路可以走.现已有m条路,求至少要新建多少条路,使得任何两个牧场之间至少有两条独立 ...
- hdu1260(dp)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1260 分析:简单dp,dp[i]=min(dp[i-1]+a[i],dp[i-2]); #includ ...
- hdu1059(多重背包)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1059 题意 : 按顺序读入一些列数,所对应的序列代表价值,数值代表个数(如a[5]=6 ,代表价值为五 ...
- Linux下SVN账户密码保存设置
Linux下用SVN进行更新等操作时,总是提示输入用户名和密码,很不方便.因此搜了下解决办法,总结如下: 打开SVN配置文件: vim /home/<user>/.subversion/c ...
- Ubuntu--有关VMware Tools安装问题
虚拟机中找不到VMware Tools选项 在虚拟机上安装了ubuntu系统后,是不可以进行系统间数据共享的,也就是说我win7系统里的文件,不能拷贝到虚拟机的ubuntu系统. 解决方案:我们需要安 ...
- SQLServer2012 分页语句执行分析
上一篇文章提到了,SQLServer2012在使用Offset,Fetch语句分页时,获取了大量不需要的数据,导致查询效率低的问题. 现在让我们来看看,究竟是什么导致SQLServer不能按需取数呢? ...
- BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第15章节--开发SP2013工作流应用程序 总结
BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第15章节--开发SP2013工作流应用程序 总结 在SP2013中,工作流已经从SP Server中脱离 ...
- poj3176--Cow Bowling(dp:数塔问题)
Cow Bowling Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 14028 Accepted: 9302 Desc ...
- CSS计数器妙用
做web的经常会遇到类似排行榜的需求, 特别是要求前n名的样式和后面人不一样. 通常大多数人对于这个需求的做法都是在后端处理好排名名次, 在前端填入内容, 然后针对前n名做特殊的样式处理. 但是这样有 ...