我需要在脚本中使用 set -x 来显示日志中执行的命令
但有一个变量是密码,因此该密码显示在计划文本中
有没有办法只隐藏一个变量?
IE:
脚本:
pas=test123
set -x
mysql -uroot -p$pas
输出:
[root@server1]# ./teste.sh
++ mysql -uroot -ptest123
我想test123
从输出中删除。
我需要在脚本中使用 set -x 来显示日志中执行的命令
但有一个变量是密码,因此该密码显示在计划文本中
有没有办法只隐藏一个变量?
IE:
脚本:
pas=test123
set -x
mysql -uroot -p$pas
输出:
[root@server1]# ./teste.sh
++ mysql -uroot -ptest123
我想test123
从输出中删除。
我有输出:
sent 66 bytes received 12 bytes 156.00 bytes/sec
total size is 204 speedup is 2.62
sending incremental file list
sent 67 bytes received 12 bytes 158.00 bytes/sec
total size is 204 speedup is 2.58
sending incremental file list
sent 66 bytes received 12 bytes 156.00 bytes/sec
total size is 204 speedup is 2.62
sending incremental file list
sent 67 bytes received 12 bytes 158.00 bytes/sec
total size is 204 speedup is 2.58
sending incremental file list
sent 67 bytes received 12 bytes 158.00 bytes/sec
total size is 204 speedup is 2.58
sending incremental file list
sent 67 bytes received 12 bytes 158.00 bytes/sec
total size is 204 speedup is 2.58
sending incremental file list
sent 67 bytes received 12 bytes 158.00 bytes/sec
total size is 204 speedup is 2.58
sending incremental file list
sent 67 bytes received 12 bytes 158.00 bytes/sec
total size is 204 speedup is 2.58
sending incremental file list
mysql-bin.000118
204 100% 0.00kB/s 0:00:00 (xfr#1, to-chk=0/1)
sent 229 bytes received 35 bytes 528.00 bytes/sec
total size is 204 speedup is 0.77
有没有办法只显示:
sending incremental file list
mysql-bin.000118
204 100% 0.00kB/s 0:00:00 (xfr#1, to-chk=0/1)
sent 229 bytes received 35 bytes 528.00 bytes/sec
total size is 204 speedup is 0.77
这是唯一丢失的文件。
编辑:谢谢 BowlOfRed,我正在使用:
rsync -azvp --progress --ignore-existing
现在我在答案中使用 as 并且它有效。
rsync -azp --info=name,progress --ignore-existing
我正在阅读/lib/systemd/system/mysqld.service
for mysql
db ,其中有一行
# Start main service
ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS
存储在哪里$MYSQLD_OPTS
?我需要检查这些值。
unzip -l
显示所有目录和子目录/文件。
我只想列出 zip 文件大小的第一个目录结构,类似于-maxdepth 1
命令find
。
如果没有整个脚本,有什么方法可以做到吗?
我在udev中做了这个配置:
KERNEL=="sdd", SYMLINK+="QUORUML", OWNER="test", GROUP="gtest", MODE="0660"
KERNEL=="sde", SYMLINK+="QUORUMR", OWNER="test", GROUP="gtest", MODE="0660"
之后,我添加了其他磁盘,新磁盘变成了旧/dev/sde
磁盘,因此上面的 udev 规则变得错误,因为名称已更改为. 如何确保正确的磁盘?有其他的身份证吗?我试过类似的东西,但由于没有分区,它不会返回任何 id。/dev/sde
/dev/sdf
sde
sdf
blkid
[root@dbnode1 rules.d]# blkid /dev/sdd
[root@dbnode1 rules.d]#
当有 iscsi 磁盘时,我会寻找类似的东西,我们可以使用 iscsi id 来做到这一点:
KERNEL=="sd?1", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/$parent", RESULT=="360014054187384e668f45e58d036f19a", SYMLINK+="disk4", OWNER="xxxx", GROUP="xxxx", MODE="0660"
对于每个多路径磁盘标签,/dev/mapper
我最后都有另一个带有 1 的标签。他们是一样的吗?有什么关系吗?
例如:
/dev/mapper/mpathaj
和/dev/mapper/mpathaj1
或
/dev/mapper/mpathai
和/dev/mapper/mpathai1
当我发出命令od --read-bytes=128 --format=c /dev/mapper/mpathai
时,磁盘看起来很干净:
[root@server02 ~]# od --read-bytes=128 --format=c /dev/mapper/mpathai
0000000 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
*
0000200
但最后 1 的另一个显示一些行:
[root@server02 ~]# od --read-bytes=128 --format=c /dev/mapper/mpathai1
0000000 001 202 001 001 \0 \0 \0 \0 003 \0 \0 200 220 . 5 213
0000020 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0000120 3 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
some characters I needed to remove to don't show costumer content.
0000160 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0000200
这发生在每个磁盘上。一个是干净的,另一个没有。
而且,我问它的原因是:我可以失去一个(mpathaj)而不会失去另一个(mpathaj1)吗?我已经看到他们指向不同的/dev/dm-xx
.
即:/dev/mapper/mpathaj
是/dev/dm-18
和/dev/mapper/mpathaj1
是/dev/dm-19
例如,如果我的 Linux 系统上的文件中有以下文本:
10-02-2020
given as file name) for lines containing a match to the given PATTERN. By default, grep prints the matching lines.
In addition, two variant programs egrep and fgrep are available. egrep is the same as grep -E. fgrep is the same as grep -F
16-02-2020
The top program provides a dynamic real-time view of a running
system. It can display system summary information as well as a list
of processes or threads currently being managed by the Linux kernel.
The types of system summary information shown and the types, order
and size of information displayed for processes are all user
configurable and that configuration can be made persistent across
restarts.
如何删除之前的所有文本16-02-2020
并将文件转换为:
16-02-2020
The top program provides a dynamic real-time view of a running
system. It can display system summary information as well as a list
of processes or threads currently being managed by the Linux kernel.
The types of system summary information shown and the types, order
and size of information displayed for processes are all user
configurable and that configuration can be made persistent across
restarts.