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 with the password student.
2. [student@stationX ~]$ pwd
/home/student
3. [student@stationX ~]$ touch {report,memo,graph}_{sep,oct,nov,dec}_{a,b,c}_{1,2,3}
4. Use the ls command to examine the results of the last command. You should find that it
created 108 new, empty files
5. [student@stationX ~]$ mkdir a_reports
[student@stationX ~]$ mkdir september october november december
Again, use ls to examine your work.
6. [student@stationX ~]$ cd a_reports
[student@stationX a_reports]$ mkdir one two three
ls
7. [student@stationX a_reports]$ cd
[student@stationX ~]$ ls -l *dec_b_?
[student@stationX ~]$ mv graph_dec_b_1 december/
[student@stationX ~]$ mv *dec_b_? december/
[student@stationX ~]$ ls -l december/
8. [student@stationX ~]$ mv *nov_b_? november/
[student@stationX ~]$ mv *oct_b_? october/
[student@stationX ~]$ mv *sep_b_? september/
9. [student@stationX ~]$ cd a_reports
[student@stationX a_reports]$ mv ~/*_a_1 one/
[student@stationX a_reports]$ cd one
[student@stationX one]$ ls *sep*
[student@stationX one]$ rm *sep*
[student@stationX one]$ ls
10. [student@stationX one]$ pwd
/home/student/a_reports/one
[student@stationX one]$ ls /home/student/*a_2*
[student@stationX one]$ mv /home/student/*a_2* /home/student/a_reports/two/
[student@stationX one]$ ls ../../*a_3*
[student@stationX one]$ mv ../../*a_3* ../three/
11. [student@stationX one]$ cd
ls
12. [student@stationX ~]$ mkdir /tmp/archive
[student@stationX ~]$ cp report*[12] /tmp/archive/
[student@stationX ~]$ cp -i report_dec* /tmp/archive/
cp: overwrite `/tmp/archive/report_dec_c_1'? n
cp: overwrite `/tmp/archive/report_dec_c_2'? n
13. [student@stationX ~]$ ls *c*
[student@stationX ~]$ ls -Fd *c*
14. [student@stationX ~]$ ls *c_[1-3]
[student@stationX ~]$ rm *c_[1-3]
[student@stationX ~]$ ls
Sequence 2: Automating tasks with shell scripts
1. Consider the command:
cp -av /etc/sysconfig ~/backups/sysconfig-yyyymmdd
2. man date
/format
date '+%Y%m%d'
3. [root@stationX ~]# mkdir ~/bin/
4. Use nano or vi, ~/bin/backupsysconfig.sh
#!/bin/bash
# This script creates a backup of /etc/sysconfig
# into a datestamped subdirectory of ~/backups/
5. add a line
cp -av /etc/sysconfig ~/backups/sysconfig-$(date '+%Y%m%d')
6. Finally, add a line
echo "Backup of /etc/sysconfig completed at: $(date)"
7. Save the file.
#!/bin/bash
# This script creates a backup of /etc/sysconfig
# into a datestamped subdirectory of ~/backups/
cp -av /etc/sysconfig ~/backups/sysconfig-$(date '+%Y%m%d')
echo "Backup of /etc/sysconfig completed at: $(date)"
8. remove today's datestamp
[root@stationX ~]# rm -rf ~/backups/sysconfig-$(date '+%Y%m%d')
9. [root@stationX ~]# chmod u+x ~/bin/backup-sysconfig.sh
10. [root@stationX ~]# ~/bin/backup-sysconfig.sh
11. If you have problems, double-check your script and try using bash -x in your shbang for
diagnostic output.
RH033读书笔记(5)-Lab 6 Exploring the Bash Shell的更多相关文章
- RH033读书笔记(11)-Lab 12 Configuring the bash Shell
Sequence 1: Configuring the bash Shell Deliverable: A system with new aliases that clear the screen, ...
- RH133读书笔记(10)-Lab 10 Exploring Virtualization
Lab 10 Exploring Virtualization Goal: To explore the Xen virtualization environment and the creation ...
- RH033读书笔记(7)-Lab 8 Introduction to String Processing
Lab 8 Introduction to String Processing Sequence 1: Exercises in string processing 1. Other than the ...
- 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读书笔记(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 ...
随机推荐
- UVALive 5791 Candy's Candy 解题报告
比赛总结 题目 题意: 有f种口味的糖果,现在要把每颗糖果分到一些packs里面去.packs分两种: flavored pack:只有一种口味. variety pack:每种口味都有. 求满足下列 ...
- 从零開始学android<Menu菜单组件.三十.>
在Android系统之中.菜单一共同拥有三类:选项菜单(OptionsMenu).上下文菜单(ContextMenu)和子菜单(SubMenu). 今天我们就用几个样例来分别介绍下菜单的使用 acti ...
- 上Https 和 http 差分
HTTPS 和 HTTP 差协议 超文本传输协定HTTP 对于web 浏览器和现场服务之间传递消息,HTTP 以纯文本协议 发送内容 无论不提供数据加密方法 假设拦截攻击web 浏览器和网站serve ...
- A Game of Thrones(17) - Bran
It seemed as though he had been falling for years. Fly, a voice whispered in the darkness, but Bran ...
- freemarker自己定义标签(二)
freemarker自己定义标签 1.自己定义标签 通过自己定义标签,写一个反复指定字符串 2.实现源代码 <html> <head> <meta http-equiv= ...
- NET工厂模式架构
NET工厂模式架构 最近项目的架构需要做调整优化,根据业务需要写了一个简单的工厂模式架构 项目介绍:整个系统分为三大平台(这里用A,B,C来标示),每个平台又细分为多个APP客户端(每个APP都有ap ...
- Oracle数据库案例整理-Oracle系统执行时故障-Shared Pool内存不足导致数据库响应缓慢
1.1 现象描写叙述 数据库节点响应缓慢,部分用户业务受到影响. 查看数据库告警日志,開始显示ORA-07445错误,然后是大量的ORA-04031错误和ORA-00600错误. 检查数据 ...
- Python内置函数str()和repr()
内建函数str()和repr() (representation.表达,表示)或反引號操作符(``)能够方便地以字符串的方式获取对象的内容.类型.数值属性等信息. str()函数得到的字符串可读性好( ...
- 蓝桥杯软件学院webserver,android
- hdu1698(线段树)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1698 线段树功能:update:成段替换 (由于只query一次总区间,所以可以直接输出1结点的信息) ...