liunx之訪問命令列
阿新 • • 發佈:2020-12-25
練習題一
使用date命令來顯示當前的日期和時間
[[email protected] ~]$ date
Wed Dec 23 11:02:47 CST 2020
練習題二
2.以12小時制顯示當前時間(例如,11:42:11AM)。提示:顯示該輸出的格式字串為%r
[[email protected] ~]$ date +%r
11:08:03 AM
練習題三
3/home/student/zcat的檔案型別是什麼?可否被人讀取?
[[email protected] ~]$ ll /home/student/ total 4 -rwxr-xr-x. 1 student student 1983 Dec 23 11:11 zcat
檔案型別:普通檔案
可否被人讀取:可以被人讀取
通 過 命 令 查 詢 文 件 類 型 \color{#FF3030}{通過命令查詢檔案型別} 通過命令查詢文件類型
[[email protected] ~]$ file zcat
zcat: POSIX shell script, ASCII text executable
練習題四
使用wc命令和bash快捷鍵顯示zcat的大小
使用wc命令顯示zcat的大小
[[email protected] ~]$ wc -c /home/student/zcat
1983 /home/student/zcat
正
確
的
操
作
:
w
c
+
E
S
C
+
.
\color{#FF3030}{正確的操作:wc+ESC+.}
正確的操作:wc+ESC+.
練習題五
顯示zcat的前10行
[[email protected] ~]$ head -10 /home/student/zcat
#!/bin/sh
# Uncompress files to standard output.
# Copyright (C) 2007, 2010-2018 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
練習題六
顯示zcat檔案後10行
[[email protected] ~]$ tail -10 /home/student/zcat
With no FILE, or when FILE is -, read standard input.
Report bugs to <[email protected]>."
case $1 in
--help) printf '%s\n' "$usage" || exit 1; exit;;
--version) printf '%s\n' "$version" || exit 1; exit;;
esac
exec gzip -cd "[email protected]"
練習題七
重複上一命令,但使用-n 20 選項來顯示檔案中最後20行。使用命令編輯功能,以通過最少擊鍵次數來完成此操縱
[[email protected] ~]$ tail -20 /home/student/zcat
-l, --list list compressed file contents
-q, --quiet suppress all warnings
-r, --recursive operate recursively on directories
-S, --suffix=SUF use suffix SUF on compressed files
--synchronous synchronous output (safer if system crashes, but slower)
-t, --test test compressed file integrity
-v, --verbose verbose mode
--help display this help and exit
--version display version information and exit
With no FILE, or when FILE is -, read standard input.
Report bugs to <[email protected]>."
case $1 in
--help) printf '%s\n' "$usage" || exit 1; exit;;
--version) printf '%s\n' "$version" || exit 1; exit;;
esac
exec gzip -cd "[email protected]"
練習題八
使用shell歷史記錄來再次執行date +%r命令
[[email protected] ~]$ history
[[email protected] ~]$ !11
date +%r
11:24:32 AM