加密你的shell,shc是一个加密shell脚本的工具。它的作用是把shell脚本转换为一个可执行的二进制文件。
用shell脚本对系统进行自动化维护,简单,便捷而且可移植性好.但shell脚本是可读写的,很有可能会泄露敏感信息,如用户名,密码,路径,IP等。同样,在shell脚本运行时会也泄露敏感信息。
shc是一个加密shell脚本的工具。它的作用是把shell脚本转换为一个可执行的二进制文件。
这就很好的解决了上述问题。
http://www.datsi.fi.upm.es/~frosal/
这里下载:shc-3.8.7.tgz
安装:
#make 生成shc文件
#cp shc /usr/local/bin/ 把shc文件拷贝到你的目录
加密shell:
shc -r -f script-name.sh
会生成2个文件,script-name.sh.x跟script-name.sh.x.c文件。
script-name.sh.x为生成的2 进制文件
script-name.sh.x.c为shell脚本转换的c文件源代码
uniq对指定的ASCII文件或标准输入进行唯一性检查,以判断文本文件中重复出现的行。常用于系统排查及日志分析。
一、版本
以红旗DC Server 5.0为例,自带版本为:
# uniq --version
uniq (coreutils) 5.2.1 |
二、常用参数
命令格式:
uniq [options] [file1 [file2] ] |
uniq从已经排序好的文本文件file1中删除重复的行,输出到标注输出或file2。常作为过滤器,配合管道使用。
在使用uniq命令前,必须确保操作的文本文件已经过sort排序。若不带参数运行uniq,将删除重复的行。
常见参数有:
-c, --count
在每行旁边显示该行重复出现的次数
-d, --repeated
仅显示重复出现的行
-D, --all-repeated[=method]
以指定的格式打印所有重复的行。格式仅适用于长选项参数,可使用none(默认),prepend,separate三个,效果见后面。以空行进行区分。
-f n, --skip-fields=n
前n个字段与每个字段前的空白一起被忽略。一个字段(fields)是一个非空格、非制表符的字符串,彼此由制表符和空格隔开(字段从1开始编号)。与-n相同,n为字段数。
-i, --ignore-case
在判断重复行时,忽略大小写区别
-s n, --skip-chars=n
前n个字符被忽略,之前的字符被跳过(字符从1开始编号)。与+n相同,n为字符数。
-u, --unique
仅显示出现一次的行
-w n, --check-chars=n
仅比较每行前面n个字符
--help
显示帮助信息
--version
显示版本信息
[输入文件]
已经排序好的文本文件或标准输入
[输出文件]
指定的输出文件,若不指定,则显示在屏幕上 |
三、示例
1、原始文件
# cat text
The year.
The year.
Second
Second
Second
Third
Third
Four |
2、-D参数结果
# uniq -D text
The year.
The year.
Second
Second
Second
Third
Third
# uniq --all-repeated=prepend text
The year.
The year.
Second
Second
Second
Third
Third
# uniq --all-repeated=separate text
The year.
The year.
Second
Second
Second
Third
Third |
3、-f和-s参数
原文:
# cat text
The year.
The year ok.
Second
Second
Second
Third
Third
Four |
参数结果:
# uniq -u text
The year.
The year ok.
Four
# uniq -u -f 1 text
The year.
The year ok.
# uniq -u -f 2 text
The year.
The year ok.
# uniq -u -f 3 text |
下面显示文件text中不重复的行,忽略前2个字段及后面的3个字符,即从第3个字段的第4个字符开始做比较:
(因为ok.后面还有\n回车符,当同第一行比较时,是有差异的)
# uniq -u -f 2 -s 3 text
The year.
The year ok.
# uniq -u -f 2 -s 4 text
# uniq -u -2 +3 text
The year.
The year ok.
# uniq -u -2 +4 text |
看多一个更简单的例子:
# cat text
test one
eest one
# uniq -u text
test one
eest one
# uniq -u -f 1 text
# uniq -u -s 1 text |
※所以,字段数和字符数都是从1开始的。
4、其他
把list文件删除重复的行后,输出到list.new中。(重复的行仅保留一行)
查看names文件中那些行是重复的
四、参考资料
原文:
http://www.oreillynet.com/linux/cmd/cmd.csp?path=u/uniq
所有的shell命令结束时都会返回退出状态(0,成功, 其他失败), 用$? 可以取得刚完成的那条命令的退出状态
rsync xxx yyy
ret=$?
if [ $ret -ne 0 ]; then
echo "失败, 错误码: $ret"
fi
付上rsync常用的错误代码:
0 Success
1 Syntax or usage error
2 Protocol incompatibility
3 Errors selecting input/output files, dirs
4 Requested action not supported: an attempt was made to manipulate 64-bit files on a platform that cannot
support them; or an option was specified that is supported by the client and not by the server.
5 Error starting client-server protocol
6 Daemon unable to append to log-file
10 Error in socket I/O
11 Error in file I/O
12 Error in rsync protocol data stream
13 Errors with program diagnostics
14 Error in IPC code
20 Received SIGUSR1 or SIGINT
21 Some error returned by waitpid()
22 Error allocating core memory buffers
23 Partial transfer due to error
24 Partial transfer due to vanished source files
25 The --max-delete limit stopped deletions
30 Timeout in data send/receive |
感谢鼎钟同学