MIT-Missing Semester_Topic 2:Shell Tools and Scripting 练习题

文章目录

      • 练习一
      • 练习二
      • 练习三
      • 练习四
      • 练习五

本 Topic 的 MIT 讲解网页(练习题未给解答)

练习一

man ls 查阅 ls 命令,并写一条以示例形式输出的 ls 命令。其涉及:显示所有文件、易阅读的文件大小、文件按时间排序、输出着色。示例:

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

按照要求查看 man ls 的信息,关键信息如下:

DESCRIPTION
       List information about the FILEs (the current directory by default).  Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
       -a, --all
              do not ignore entries starting with .
       -c     with  -lt:  sort  by,  and  show, ctime (time of last modification of file status information); with -l: show ctime and sort by name; otherwise: sort by ctime, newest first
       --color[=WHEN]
              colorize the output; WHEN can be 'always' (default if omitted), 'auto', or 'never'; more info below
       -h, --human-readable
              with -l and -s, print sizes like 1K 234M 2G etc.

综上,可以得到答案:ls -a -lt --color -h,结果如下:

cowbby@LAPTOP-UD6DKAMF:~/Missing Semester/2_Shell Tools and Scripting/test$ ls -a -lt --color -h
total 4.0K
-rwxr--r-- 1 cowbby cowbby  906 Jan 26 15:51 append_foobar.sh
-rwxr-xr-x 1 cowbby cowbby  129 Jan 26 15:48 script.py
drwxr-xr-x 1 cowbby cowbby 4.0K Jan 26 15:41 .
drwxr-xr-x 1 cowbby cowbby 4.0K Jan 26 15:41 ..
drwxr-xr-x 1 cowbby cowbby 4.0K Jan 26 15:38 Bar
drwxr-xr-x 1 cowbby cowbby 4.0K Jan 26 15:38 Foo
drwxr-xr-x 1 cowbby cowbby 4.0K Jan 26 15:35 project2
drwxr-xr-x 1 cowbby cowbby 4.0K Jan 26 15:35 project1
-rw-r--r-- 1 cowbby cowbby   13 Jan 26 15:33 bar.txt
-rw-r--r-- 1 cowbby cowbby   13 Jan 26 15:33 foo.txt
-rw-r--r-- 1 cowbby cowbby    0 Jan 26 15:33 foo1
-rw-r--r-- 1 cowbby cowbby    0 Jan 26 15:33 foo2
drwxr-xr-x 1 cowbby cowbby 4.0K Jan 26 15:29 fooPJ2
drwxr-xr-x 1 cowbby cowbby 4.0K Jan 26 15:29 fooPJ32
drwxr-xr-x 1 cowbby cowbby 4.0K Jan 26 15:29 fooPJ1

练习二

练习三

练习四

练习五

你可能感兴趣的:(MIT,-,Missing,Semester,bash)