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 ...
随机推荐
- iOS学习——JSON数据解析(十一)
在之前的<iOS学习——xml数据解析(九)>介绍了xml数据解析,这一篇简单介绍一下Json数据解析.JSON 即 JavaScript Object Natation,它是一种轻量级的 ...
- 开发腾讯移动游戏平台SDK Android版Ane扩展 总结
本文记录了在开发 腾讯移动游戏平台SDK(MSDK) Android版Ane扩展 过程中所遇到的问题和相关解决方式 问题一:编译报错:Unable to resolve target 'android ...
- g++编C++11/C++0x遇到的问题
在看<Cplusplus Concurrency In Action Practical Multithreading>当遇到第一个样品: #include<iostream> ...
- Web工程师的工具箱 | 酷壳 - CoolShell.cn
Web工程师的工具箱 | 酷壳 - CoolShell.cn Web工程师的工具箱 2012年12月19日 陈皓 发表评论 阅读评论 30,168 人阅读 本文出自Ivan Zuzak 的&l ...
- HBase经常使用操作之namespace
1.介绍 在HBase中,namespace命名空间指对一组表的逻辑分组,类似RDBMS中的database,方便对表在业务上划分.Apache HBase从0.98.0, 0.95.2两个版本号開始 ...
- 依据二度人脉推荐好友sql
friend表结构 DROP TABLE IF EXISTS FRIEND; create table friend( uid bigint not null comment ' ...
- jquery validation remote depends 验证触发条件
背景: 1:简介页面的变化: 2:邮箱不能反复 改动页面,邮箱默认带出,但字段上带有remote验证.不能反复,焦点由邮箱输入框失去时.会默认触发remote验证. 介绍完成 watermark/2/ ...
- namespace命名空间
在讨论如何使用命名空间之前,必须了解 PHP 是如何知道要使用哪一个命名空间中的元素的.可以将 PHP 命名空间与文件系统作一个简单的类比.在文件系统中访问一个文件有三种方式: 相对文件名形式如foo ...
- 在ubuntu安装Phabricator(转)
前言: Phabricator是facebook团队进行codereview的一个工具,是基于php进行开发的.界面简洁优雅,是团队做代码评审的好帮手.个人认为,是当前最好的code review平台 ...
- DOM解析XML文件实例
XML文件: response: <?xml version="1.0"?> <soap:Envelope xmlns:soap="http://www ...