测试机器的硬件信息:
1)查看CPU信息(型号)
# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
8 Intel(R) Xeon(R) CPU E5410 @ 2.33GHz
(看到有8个逻辑CPU, 也知道了CPU型号)
2)# cat /proc/cpuinfo | grep physical | uniq -c
4 physical id : 0
4 physical id : 1
(说明实际上是两颗4核的CPU)
3)# getconf LONG_BIT
32
(说明当前CPU运行在32bit模式下, 但不代表CPU不支持64bit)
4)# cat /proc/cpuinfo | grep flags | grep ' lm ' | wc -l
8
(结果大于0, 说明支持64bit计算. lm指long mode, 支持lm则是64bit)
再完整看cpu详细信息, 不过大部分我们都不关心而已.
=============================================
5)查看内 存信息
# cat /proc/meminfo
6)# uname -a
Linux euis1 2.6.9-55.ELsmp #1 SMP Fri Apr 20 17:03:35 EDT 2007 i686 i686 i386 GNU/Linux
(查看当前操作系统内核信息)
6)# cat /etc/issue | grep Linux
Red Hat Enterprise Linux AS release 4 (Nahant Update 5)
(查看当前操作系统发行版信息)
7)查看机器型号
# dmidecode | grep "Product Name"
8)查看网卡信息
# dmesg | grep -i eth
=============================================
=============================================
cut:http://tiankonghaikuo1000.blog.163.com/blog/static/182315972008212856182/
$ cut --help
Usage: cut [OPTION]... [FILE]...
Print selected parts of lines from each FILE to standard output.
Mandatory arguments to long options are mandatory for short options too.
-b, --bytes=LIST select only these bytes
-c, --characters=LIST select only these characters
-d, --delimiter=DELIM use DELIM instead of TAB for field delimiter
-f, --fields=LIST select only these fields; also print any line
that contains no delimiter character, unless
the -s option is specified -n (ignored)
--complement complement the set of selected bytes, characters
or fields.
-s, --only-delimited do not print lines not containing delimiters
--output-delimiter=STRING use STRING as the output delimiter
the default is to use the input delimiter
--help display this help and exit
--version output version information and exit
Use one, and only one of -b, -c or -f. Each LIST is made up of one
range, or many ranges separated by commas. Selected input is written
in the same order that it is read, and is written exactly once.
Each range is one of:
N N'th byte, character or field, counted from 1
N- from N'th byte, character or field, to end of line
N-M from N'th to M'th (included) byte, character or field
-M from first to M'th (included) byte, character or field
With no FILE, or when FILE is -, read standard input.
Report bugs to <bug-coreutils@gnu.org>.
========================================================================
cut -c1,5,13 file 取出第1个 第5个 第13个 字符
cut -c-5 file 取出前5个字符
cut -c5-13 file
cut -c13- file
cut -c1-5, 13- file
等等..
cut -d' ' -f2 file
取出第二个域 默认情况下 对于没有分隔符的 也会被取出来
cut -d' ' -s -f2 file
同上, 只是 没有分隔符的行不会被 output
这个与 awk '{ print $2 }' file 比较, 后者对没有分隔符的行会打印一个空行
实际等同于 awk '{ if( $2 ){ print $2 } }' file
注: cut 默认以 \t 为分隔符而不是 空格 awk 均可.
================================
cut 使用 -d 选项 一定要结合 -f 选项。