1. Back up the/etc directory to the current directory, the file name of the backup files is named after the source directory name and the time date on the server
[Email protected] ~]# tar CFZ etc-
date +%x\(%H-%M-%S\)
. tar.gz/etc
[Email protected] ~]# tar cfz etc_$ (date +%f (%h-%m-%s)). tar.gz/etc
2. Display the last modified time of the file
[Email protected] ~]# date-r FILENAME +%f (%h-%m-%s)
[[email protected] ~]# echo ' Last Modification time: '
date -r FILENAME +%F\(%H-%M-%S\)
[Email protected] ~]# echo ' The Last modification time is: '
date -r FILENAME +%Z,%F,%P\:\(%H-%M-%S\)
[Email protected] ~]# echo ' The Last modification time is: '; Date-r FILENAME +%z,%f,%p\:(%h-%m-%s)
3. Displays a file that was last modified in the current directory
[Email protected] ~]# LS-LRT | Tail-1
[Email protected] ~]# echo-e "The Last File modified was:\033[1m$ (ls-t | head-1) \033[0m "
#取出当前目录下最近一次被修改的文件名
[Email protected] ~]# name=
ls -rt | tail -1
# [[email protected] ~]# echo $name
4. View the current operating level of the system
[Email protected] ~]# Who-r | awk ' {print $1,$2} '
[Email protected] ~]# echo-e "\033[1m$ (Who-r | awk ' {print $1,$2} ') \033[0m "
5. Export the man manual page content to a file
[[email protected] ~]# Man COMMAND | Col-b > FILENAME
6. Do not allow overwriting of existing regular files via redirected output
[Email protected] ~]# set-c
#只对当前的shell有效
7. Test whether the command was executed successfully
[[email protected] ~]# COMMAND && [$? = 0] && echo-e "\033[1;32m ok \033[0m" | | echo-e "\033[5;31M ER ROR \033[0m "
[[email protected] ~]# COMMAND && [$-eq 0] && echo-e "\033[1;32m ok \033[0m" | | echo-e "\033[5;31M E Rror \033[0m "
8. Switch back and forth between the last working directory and the current directory
[Email protected] ~]# CD-
9. Sequential and identical commands are not recorded in the history command
[Email protected] ~]# export histcontrol=ignoredups
10. View Public IP
[Email protected] ~]# Curl ifconfig.me
[Email protected] ~]# Curl Members.3322.org/dyndns/getip
[Email protected] ~]# Curl cip.cc
Linux command-line tips