Chap2

1. 作业答案

Q1: 阅读 man ls ,然后使用ls 命令进行如下操作:

  • 列出所有文件信息:-l
  • 所有文件(包括隐藏文件) :-a
  • 文件打印以人类可以理解的格式输出 (例如,使用454M 而不是 454279954) : -h
  • 文件以最近访问顺序排序:-t
  • 以彩色文本显示输出结果:—color=auto

典型输出如下:

1
2
3
4
5
-rw-r--r--   1 user group 1.1M Jan 14 09:53 baz
drwxr-xr-x 5 user group 160 Jan 14 09:53 .
-rw-r--r-- 1 user group 514 Jan 14 06:42 bar
-rw-r--r-- 1 user group 106M Jan 13 12:12 foo
drwx------+ 47 user group 1.5K Jan 12 18:08 ..

A:

1
ls -lhat --color=auto

Q2: 编写两个bash函数 marco 和 polo 执行下面的操作。每当你执行 marco 时,当前的工作目录应当以某种形式保存,当执行 polo 时,无论现在处在什么目录下,都应当 cd 回到当时执行 marco 的目录。为了方便debug,你可以把代码写在单独的文件 marco.sh 中,并通过 source marco.sh命令,(重新)加载函数。

A:

Donate
  • Copyright: Copyright is owned by the author. For commercial reprints, please contact the author for authorization. For non-commercial reprints, please indicate the source.
  • Copyrights © 2022-2024 CPY
  • Visitors: | Views:

请我喝杯咖啡吧~

支付宝
微信