Linux小推车Linux基础

Linux Day4: more/less/touch

2018-10-05  本文已影响36人  泥人吴

1. more 一页一页的显示档案内容。

$ more /etc/inputrc
# /etc/inputrc - global inputrc for libreadline
# See readline(3readline) and `info rluserman' for more information.

# Be 8 bit clean.
set input-meta on
set output-meta on

# To allow the use of 8bit-characters like the german umlauts, uncomment
# the line below. However this makes the meta key not work as a meta key,
# which is annoying to those which don't need to type in 8-bit characters.

# set convert-meta off

# try to enable the application keypad when it is called.  Some systems
# need this to enable the arrow keys.
# set enable-keypad on

# see /usr/share/doc/bash/inputrc.arrows for other codes of arrow keys

# do not bell on tab-completion
# set bell-style none
# set bell-style visible

# some defaults / modifications for the emacs mode
$if mode=emacs

# allow the use of the Home/End keys
"\e[1~": beginning-of-line
"\e[4~": end-of-line

# allow the use of the Delete/Insert keys
"\e[3~": delete-char
最后一行 more命令

对于52%的说明:more 后面接的档案内容行数大亍屏幕输出的行数时, 就会出现类似上面的图示。最后一行会显示出目前显示癿百分比, 而且还可以在最后一行输入一些有用的指令:
按下enter:

enter

2. less 与 more 类似,但是比 more 更好的是,他可以往前翻页,也可以向前搜索!

其命令有:

这个为使用less搜索文件后的:less /etc/inputrc

less

3.修改档案时间或建置新档: touch

选项与参数:
-a :仅修订 access time;
-c :仅修改档案的时间,若该档案不存在则不建立新档案;
-d :后面可以接欲修订的日期而不用目前的日期,也可以使用 --date="日期或时间"
-m :仅修改 mtime ;
-t :后面可以接欲修订的间而不用目前的时间,格式为[YYMMDDhhmm]

linux 底下都会记录许多的时间参数, 其实是有三个主要的变动时间,那么三个时间的意义是什么呢?

$ cd /tmp
$ pwd
/tmp
$ touch testtouch
$ ls -l testtouch
-rw-rw-r-- 1 ywu ywu 0 Oct  5 18:49 testtouch

这个档案的大小是 0 呢!在预设的状忞下,如果 touch 后面有接档
案, 则该档案的三个时间 (atime/ctime/mtime) 都会更新为目前的时间。若该档案不存在,则会建立一个新的空的档案喔!
范例二:修改案例二的testtouch档案,将日期调整为两天前

$ touch -d "2 days ago" testtouch
$ ls -l testtouch
-rw-rw-r-- 1 ywu ywu 0 Oct  3 18:56 testtouch

范例三:将上个范例的testtouch 日期改为 2018/10/05 2:02

$ touch -t 1810050202 testtouch
$ ls -l testtouch
-rw-rw-r-- 1 ywu ywu 0 Oct  5 02:02 testtouch
上一篇 下一篇

猜你喜欢

热点阅读