The prerequisite for the host system.
cat > version-check.sh << "EOF" #!/bin/bash
# Simple script to list version numbers of critical development tools
bash --version | head -n1 | cut -d" " -f2-4 echo -n "Binutils: "; ld --version | head -n1 | cut -d" " -f3-4 bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d" " -f1,6- echo -n "Coreutils: "; chown --version | head -n1 | cut -d")" -f2 diff --version | head -n1 find --version | head -n1 gawk --version | head -n1 gcc --version | head -n1 /lib/libc.so.6 | head -n1 | cut -d" " -f1-7 grep --version | head -n1 gzip --version | head -n1 cat /proc/version | head -n1 | cut -d" " -f1-3,5-7 make --version | head -n1 patch --version | head -n1 sed --version | head -n1 tar --version | head -n1 |
对其中的几个命令还不是很了解。
1,cut
!-c命令选项显示文件每行的制定字符 cat myfile #file #hello.sh cut -c1-4 myfile The output: #file #hell 还可以非连续的形式 cut -c1-4,6-7 myfile -c之后的几种选择: m 第m个字符或字段 m- 从第m个字符或字段到文件结束 m-n 从第m个到第n个字符或字段 -n 从第1个到第n个字符或字段 这对于-f命令是通用的。
|
!-f命令显示文件的制定栏数,默认以tab键分割而不是空格 cat test #This is for test. Is the TAB button the delimiter? cut -f1 test #This is for test. 可以使用-d选项指定分隔符。 cut -d" " -f4-5 test -f选项之后的几种选择可以参照-c。
|
2,head
head命令比较简单,用于截取文件的头几行。默认是10行,相当于使用了-n10命令选项。也可以通过-n命令指定截取的行数。
3,diff命令的简单使用
用于比较两个文件,当两个文件被认为内容相同时不会产生任何输出。否则会产生如下形式的输出:
#命令形式 diff file1 file2 当file1,或者file2写为“-”表示从标准输入读取内容。 #依次表示的是append,delete,change,“....”代表的是行号。 ....a|d|c.... #<,> <表示的是file1中的某行。 >表示的是file2中的某行。
|
常用的命令选项:
- -b
- 忽略空格引起的变化.
- -r
- 当比较目录时,递归比较任何找到的子目录.
|
以下是两个用于测试diff命令的文件。
cat test1 #This is for test. cp test1 test2
|
#script
diff test1 test2 vi test1#在test1中输入若干的空格。 diff test1 test2 #1c1 ##--- #>This is for test diff -b test1 test2 cp test1 test2 #在test1加入一行:This is an appended line.执行以上命令: #2d1 #diff test2 test1 #1a2 #>This is an appended line.
|
阅读(654) | 评论(0) | 转发(0) |