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 ...
随机推荐
- Jobbox.io(职位盒子): 新兴的面向技术人才的职场招聘众推平台
人才招聘市场一个主要问题在于猎头中介费昂贵.这对于大公司而言,或可接受. 但对于海量小微企业而言招聘成本和效率之间的平衡是非常大的一个问题. 现在产品猎场(Product Hunt)上出现了一些新的招 ...
- contiki etimer部分
1.前言 contiki是一款小型开源,易于移植的多任务操作系统,专门为无线传感网设计,适合内存受限制的网络系统.国内的研究和应用还处于初级阶段,甚至还不知道这个contiki如何发音,也没有 ...
- BZOJ 2809 APIO2012 dispatching Treap+启示式合并 / 可并堆
题目大意:给定一棵树,选定一棵子树中的一些点,薪水和不能超过m,求点的数量*子树根节点的领导能力的最大值 考虑对于每一个节点,我们维护一种数据结构,在当中贪心寻找薪金小的雇佣. 每一个节点暴力重建一定 ...
- 从零开始,使用python快速开发web站点(1)
环境:ubuntu 12.04 python版本: 2.73 ok,首先,既然是从零开始,我们需要的是一台可以运行的python的计算机环境,并且假设你已经安装好了python, (ubuntu 或 ...
- HTML表格标签的使用-<table>
<html> <head> <title> 表格标签 </title> <!-- 标签名:table 定义一个表格 子标签:<caption ...
- vim忽略大写和小写查找配置
作者:zhanhailiang 日期:2014-12-17 默认 vim 的查找是区分大写和小写,可通过下面两种方式实现忽略大写和小写查找 set ic? noignorecase 1 指令设定: : ...
- poj3264(线段树区间求最值)
题目连接:http://poj.org/problem?id=3264 题意:给定Q(1<=Q<=200000)个数A1,A2,```,AQ,多次求任一区间Ai-Aj中最大数和最小数的差. ...
- AndroidMainFest.xml file missing!
今天在导入项目的时候出现了这种错误: 仅仅须要一步 就搞定: projecct ---> clean 又一次编译一下就可以搞定了.
- Knockout应用开发指南 第六章:加载或保存JSON数据
原文:Knockout应用开发指南 第六章:加载或保存JSON数据 加载或保存JSON数据 Knockout可以实现很复杂的客户端交互,但是几乎所有的web应用程序都要和服务器端交换数据(至少为了本地 ...
- linux su,sudo命令
linux su 命令 建议大家切换用户的时候 使用 su - root 这样,否则可能发现某些命令执行不了 关于su .su - 及 sudo的区别 请往下看 1.命令作用 su的作用是变更为其它使 ...