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- ...
随机推荐
- GitHub上最火的40个iOS开源项目
1. AFNetworking 在众多iOS开源项目中,AFNetworking可以称得上是最受开发者欢迎的库项目.AFNetworking是一个轻量级的iOS. Mac OS X网络通信类库,现在是 ...
- OCP读书笔记(7) - 使用RMAN执行恢复
7.Using RMAN to Perform Recovery 使用RMAN进行完全恢复system表空间文件丢失的恢复 模拟损坏: SQL> conn /as sysdba; SQL> ...
- Mod in math
An Introduction to Modular Math When we divide two integers we will have an equation that looks like ...
- 关于JVM的ClassLoader(转)
众所周知,java是编译型的语言,写的是java文件,最后运行的是class文件,class文件是运行在JVM之中的,这时候就有一个问题,JVM如何装载class文件的?是通过ClassLoader来 ...
- zoj3471(状压dp)
题目连接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4257 题意:不超过10种气体,两两之间相互碰撞可以产生一定的能量,如 ...
- MySQL中CASE的使用
语法说明: 方式一: CASE value WHEN [compare_value] THEN result [WHEN [compare_value] THEN result ...] [ELSE ...
- poj3264(线段树区间求最值)
题目连接:http://poj.org/problem?id=3264 题意:给定Q(1<=Q<=200000)个数A1,A2,```,AQ,多次求任一区间Ai-Aj中最大数和最小数的差. ...
- HTML中的div标签
在网页制作过程过中,能够把一些独立的逻辑部分划分出来.放在一个<div>标签中,这个<div>标签的作用就相当于一个容器. 为了使逻辑更加清晰,我们能够为这一个独立的逻辑部分设 ...
- linux--关于shell的介绍
下面是最近学习shell的一些知识点总结***博客园-邦邦酱好*** 1.什么是shell(1)Shell将我们输入的指令与Kernel沟通,好让Kernel可以控刢硬件来正确无误地工作.(2)我们总 ...
- Mysql经常使用命令
1.导出整个数据库 mysqldump -u username -p --default-character-set=latin1 数据库名 > 导出的文件名称(数据库默认编码是latin1) ...