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的更多相关文章

  1. RH033读书笔记(11)-Lab 12 Configuring the bash Shell

    Sequence 1: Configuring the bash Shell Deliverable: A system with new aliases that clear the screen, ...

  2. RH133读书笔记(10)-Lab 10 Exploring Virtualization

    Lab 10 Exploring Virtualization Goal: To explore the Xen virtualization environment and the creation ...

  3. RH033读书笔记(7)-Lab 8 Introduction to String Processing

    Lab 8 Introduction to String Processing Sequence 1: Exercises in string processing 1. Other than the ...

  4. RH033读书笔记(15)-Lab 16 The Linux Filesystem

    Lab 16 The Linux Filesystem Goal: Develop a better understanding of Linux filesystem essentials incl ...

  5. 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 ...

  6. RH033读书笔记(4)-Lab 5 File Permissions

    Lab 5 File Permissions Sequence 1: Determining File Permissions 1. What is the symbolic representati ...

  7. RH033读书笔记(3)-Lab 4 Browsing the Filesystem

    Lab 4 Browsing the Filesystem Sequence 1: Directory and File Organization 1. Log in as user student ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. ruby on rails创建的页面訪问很慢

    ruby on rails创建的页面訪问很慢 用rvm安装的ruby1.9.3 解决:cd ~/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/1.9.1/webrick v ...

  2. projecteuler---->problem=9----Special Pythagorean triplet

    title: A Pythagorean triplet is a set of three natural numbers, a b c, for which, a2 + b2 = c2 For e ...

  3. ASA QOS限速

    cisco的Qos限速和H3C的有点区别,不过总体来说,H3C的比较渣,单位是不一样的,H3C 的CAR单位的是kpbs,而cisco police限速时的单位是Bits per seconds,H3 ...

  4. hbase基本概念和hbase shell经常使用命令使用方法

    HBase是一个分布式的.面向列的开源数据库,源于google的一篇论文<bigtable:一个结构化数据的分布式存储系统>.HBase是Google Bigtable的开源实现,它利用H ...

  5. hdu1254(bfs+dfs)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1254 分析: 真正移动的是箱子,但是要移动箱子需要满足几个条件. 1.移动方向上没有障碍. 2.箱子后 ...

  6. Vagrant - 百度百科

    http://wapbaike.baidu.com/view/9201587.htm?ssid=0&from=844b&uid=3151E6C0905477A13653132D762B ...

  7. Node.js: What is the best "full stack web framework" (with scaffolding, MVC, ORM, etc.) based on Node.js / server-side JavaScript? - Quora

    Node.js: What is the best "full stack web framework" (with scaffolding, MVC, ORM, etc.) ba ...

  8. 多个UpdatePanel控件相互引发刷新的使用

    原文:多个UpdatePanel控件相互引发刷新的使用 ScriptManager和UpdatePanel控件联合使用可以实现页面异步局部更新的效果.其中的UpdatePanel就是设置页面中异 步局 ...

  9. 完美攻略心得之圣魔大战3(Castle Fantisia)艾伦希亚战记(艾伦西亚战记)包含重做版(即新艾伦希亚战记)

    (城堡幻想曲3,纠正大家个错误哦,不是圣魔大战3,圣魔大战是城堡幻想曲2,圣魔大战不是个系列,艾伦西亚战记==艾伦希亚战记,一个游戏日文名:タイトル キャッスルファンタジア -エレンシア戦記-リニュー ...

  10. wp天气预报

    ak url  http://developer.baidu.com/map/index.php?title=car 后台cs using System; using System.Collectio ...