欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  科技

[20190505]ts 命令在哪里.txt

程序员文章站 2022-11-15 21:09:11
[20190505]ts 命令在哪里.txt--//在论坛问一下ts命令在哪里?没人解答,自己也google看了一下:https://unix.stackexchange.com/questions/272433/piping-into-moreutils-ts-with-nanosecond-pr ......

[20190505]ts 命令在哪里.txt

--//在论坛问一下ts命令在哪里?没人解答,自己也google看了一下:
https://unix.stackexchange.com/questions/272433/piping-into-moreutils-ts-with-nanosecond-precision

--//however, if i use the same format string with moreutils' ts, the nanosecond precision fails:

--//应该在1个moreutils包里面.
--//另外注意有如下都不是:

#  ls -l ts-0.7.3-1.2.x86_64.rpm task-spooler-1.0-1.3.el6.x86_64.rpm
-rw-r--r-- 1 root root 40628 2019-05-05 16:02:38 task-spooler-1.0-1.3.el6.x86_64.rpm
-rw-r--r-- 1 root root 46792 2019-05-05 09:18:37 ts-0.7.3-1.2.x86_64.rpm

--//找到半天仅仅找到rhel 7 的rpm包.
http://rpm.pbone.net/index.php3/stat/4/idpl/55075202/dir/centos_7/com/moreutils-0.49-2.el7.x86_64.rpm.html

# ls -l moreutils-0.49-2.el7.x86_64.rpm perl-*
-rw-r--r--. 1 root root  77156 2019-05-05 16:16:44 moreutils-0.49-2.el7.x86_64.rpm
-rw-r--r--. 1 root root  39464 2019-05-05 16:27:12 perl-io-1.25-2.2.x86_64.rpm
-rw-r--r--. 1 root root  42580 2019-05-05 16:31:03 perl-io-tty-1.10-11.el7.x86_64.rpm
-rw-r--r--. 1 root root 124524 2019-05-05 16:21:30 perl-ipc-run-0.92-2.el7.noarch.rpm
-rw-r--r--. 1 root root  52744 2019-05-05 16:23:37 perl-timedate-2.30-2.el7.noarch.rpm
-rw-r--r--. 1 root root  16872 2019-05-05 16:21:37 perl-time-duration-1.06-17.8.noarch.rpm

# rpm -ivh moreutils-0.49-2.el7.x86_64.rpm perl-ipc-run-0.92-2.el7.noarch.rpm perl-timedate-2.30-2.el7.noarch.rpm perl-time-duration-1.06-17.8.noarch.rpm perl-io-tty-1.10-11.el7.x86_64.rpm
warning: moreutils-0.49-2.el7.x86_64.rpm: header v3 dsa/sha1 signature, key id 9dbd524d: nokey
warning: perl-ipc-run-0.92-2.el7.noarch.rpm: header v3 rsa/sha256 signature, key id f4a80eb5: nokey
preparing...                          ################################# [100%]
updating / installing...
   1:perl-io-tty-1.10-11.el7          ################################# [ 20%]
   2:perl-ipc-run-0.92-2.el7          ################################# [ 40%]
   3:perl-time-duration-1.06-17.8     ################################# [ 60%]
   4:perl-timedate-1:2.30-2.el7       ################################# [ 80%]
   5:moreutils-0.49-2.el7             ################################# [100%]

# file /usr/bin/ts
/usr/bin/ts: perl script, ascii text executable


# yes | ts | uniq -c
  18069 may 05 16:32:23 y
  72879 may 05 16:32:24 y
  50330 may 05 16:32:25 y
  50756 may 05 16:32:26 y
  67530 may 05 16:32:27 y
  59702 may 05 16:32:28 y
  74953 may 05 16:32:29 y

# ping -i 2 -c 3 192.168.100.40|ts  '%y-%m-%d %h:%m:%.s'
2019-05-05 16:35:51.603349 ping 192.168.100.40 (192.168.100.40) 56(84) bytes of data.
2019-05-05 16:35:51.603458 64 bytes from 192.168.100.40: icmp_seq=1 ttl=63 time=0.502 ms
2019-05-05 16:35:53.581129 64 bytes from 192.168.100.40: icmp_seq=2 ttl=63 time=0.286 ms
2019-05-05 16:35:55.581410 64 bytes from 192.168.100.40: icmp_seq=3 ttl=63 time=0.279 ms
2019-05-05 16:35:55.581510
2019-05-05 16:35:55.581531 --- 192.168.100.40 ping statistics ---
2019-05-05 16:35:55.581548 3 packets transmitted, 3 received, 0% packet loss, time 4000ms
2019-05-05 16:35:55.581565 rtt min/avg/max/mdev = 0.279/0.355/0.502/0.105 ms

--//%.s显示秒后面的时间.精度更高.

# ping -i 1 -c 4 192.168.100.40|ts -i  '%.s'
00.000020 ping 192.168.100.40 (192.168.100.40) 56(84) bytes of data.
00.000083 64 bytes from 192.168.100.40: icmp_seq=1 ttl=63 time=0.489 ms
00.978879 64 bytes from 192.168.100.40: icmp_seq=2 ttl=63 time=0.335 ms
00.999936 64 bytes from 192.168.100.40: icmp_seq=3 ttl=63 time=0.280 ms
01.000335 64 bytes from 192.168.100.40: icmp_seq=4 ttl=63 time=0.313 ms
00.000073
00.000010 --- 192.168.100.40 ping statistics ---
00.000007 4 packets transmitted, 4 received, 0% packet loss, time 3000ms
00.000008 rtt min/avg/max/mdev = 0.280/0.354/0.489/0.081 ms

--//里面还有1些小工具.其中vidir有点恐怖有意思,可以实现像文本编辑器那样修改文件以及目录:

# man vidir
vidir(1)                                                                                                                                                                                                                                                        vidir(1)

name
       vidir - edit directory

synopsis
       vidir [--verbose] [directory|file|-] ...

description
       vidir allows editing of the contents of a directory in a text editor. if no directory is specified, the current
       directory is edited.

       when editing a directory, each item in the directory will appear on its own numbered line. these numbers are how
       vidir keeps track of what items are changed. delete lines to remove files from the directory, or edit filenames
       to rename files. you can also switch pairs of numbers to swap filenames.

       note that if "-" is specified as the directory to edit, it reads a list of filenames from stdin and displays
       those for editing. alternatively, a list of files can be specified on the command line.

--//演示如下:
# ls -l
total 0
-rw-r--r--. 1 root root 0 2019-05-05 16:48:29 aaa
-rw-r--r--. 1 root root 0 2019-05-05 16:48:32 bbb
drwxr-xr-x. 2 root root 6 2019-05-05 16:48:37 ccc

# vidir
1       ./aaa
2       ./bbb
3       ./ccc

--//修改如下保存,注意前面的编号不要修改:
1       ./aaa1
2       ./bbb2
3       ./ccc3

# ls -l
total 0
-rw-r--r--. 1 root root 0 2019-05-05 16:48:29 aaa1
-rw-r--r--. 1 root root 0 2019-05-05 16:48:32 bbb2
drwxr-xr-x. 2 root root 6 2019-05-05 16:48:37 ccc3

--//如果你删除了一行,对应的文件在保存后就删除了.当然我的测试如果目录非空好像不会删除.会报目录非空.