1:
默认情况下,mysql使用MyISAM表类型,其为SELECT的速度而优化,大多数网站使用这种表,因为网站很少使用INSERT和UPDATE语句,而经常会用到SELECT语句。
2:
mysql中有三种主要的列类型:数字、字符串、日期。
3:
数字类型主要分为两种:整型和浮点型。所有的数字类型允许两个选项:UNSIGNED和ZEROFILL。
UNSIGNED不允许有负数(将整数的范围扩大),而ZEROFILL为该值添加上零,而不是常用的空格,并且自动把它变为UNSIGNED。
4:
mysql可用的数字类型如下:
tinyint
bit
bool
smallint
mediumint
int
integer
bigint
float
double
5:
mysql可用的字符串类型:
char
varchar
tinyblog
tinytext
blob
text
mediumblob
mediumtext
longblob
longtext
enum
set
6:
从速度方面考虑,要选择固定的列,如CHAR;
为了节省空间,使用动态的列,如VARCHAR;
为了将列中的内容限制在一种选择,使用ENUM;
为了在一个列中有多于一个的条目,选择SET;
对于想搜素的大小写不相关文本,使用TEXT;
对于想搜素的大小写相关文本,使用BLOB;
7:
默认情况下,CHAR VARCHAR类型在搜索时是大小写不相关的,除非你使用BINARY关键字。
在大多数的DBMS中,大小写不相关的搜索CHAR和VARCHAR字段是不常见的,所以要谨慎对待这一点。
8:
mysql可用的日期类型如下:
datetime
date
timestamp
time
year
9:
事务安全的表类型为:InnoDB和BDB;
其他表类型如ISAM、MyISAM、MERGE和HEAP都不是事务安全的。
功能:
文件经过处理后在它的输出文件中可能会出现重复的行。例如,使用cat命令将两个文件合并后,再使用sort命令进行排序,就可能出现重复行。这时可以使用uniq命令将这些重复行从输出文件中删除,只留下每条记录的唯一样本。
语法:
uniq [选项] 文件
说明:
这个命令读取输入文件,并比较相邻的行。在正常情况下,第二个及以后更多个重复行将被删去,行比较是根据所用字符集的排序序列进行的。该命令加工后的结果写到输出文件中。输入文件和输出文件必须不同。如果输入文件用“- ”表示,则从标准输入读取。
该命令各选项含义如下:
– c
显示输出中,在每行行首加上本行在文件中出现的次数。它可取代- u和- d选项。
– d
只显示重复行。
– u
只显示文件中不重复的各行。
– n
前n个字段与每个字段前的空白一起被忽略。一个字段是一个非空格、非制表符的字符串,彼此由制表符和空格隔开(字段从0开始编号)。
+n
前n个字符被忽略,之前的字符被跳过(字符从0开始编号)。
– f n
与- n相同,这里n是字段数。
– s n
与+n相同,这里n是字符数。
举例:
有文件a.txt,内容如下:
[160]/boss18/work/darkmi/test/>more a.txt
aaaa
aaaa
bbbb
cccc
dddd
aaaa
eeee
aaaa
执行uniq命令,输出如下:
[160]/boss18/work/darkmi/test/>uniq a.txt
aaaa
bbbb
cccc
dddd
aaaa
eeee
aaaa
说明:
uniq是删除连续的重复行,对于未连续的重复行并没有删除,所以想要删除所有重复行,最后使用sort对文件进行排序。
paste
用途:paste用来合并文件行或输出。
举例:who|awk\'{print $1}\’|paste–。这个命令执行后获得当前用户ID并将它们按行列格式打印。两个-符号指定列的形式。
用途:nroff将文本文件格式化为行式打印机或终端屏幕所需要的形式。
举例:nroff myfile.txt。这个命令执行后将产生一个清楚的、格式优美的输出结果。
据说是十几年前用Unix的人是用nroff/troff来印文件,不过现在几乎没人在用了!
维基爽关于troff的介绍:http://zh.wikipedia.org/wiki/Troff
gzip
用途:gzip用来压缩或解压缩文件。
举例:gzip myfile.txt。这个命令执行时对myfile.txt进行压缩,产生一个名叫myfile.txt.gz的压缩文件。该压缩文件可以使用gzip或gunzip进行解压缩(将这个命令和gunzip进行比较)。
gunzip
用途:gunzip用来压缩或解压缩文件(通常是那些带有.gz扩展名的文件)。
举例:gunzip myfile.txt.gz。这个命令执行后将解压缩myfile.txt文件。
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
温习之后做的的另外一篇关于gzip的笔记:http://www.darkmi.com/blog/archives/964
gzip只能压缩单个文件,所以如果想同时压缩多个文件的话,可以可以先将这几个文件打包(tar)到一个单独的文件中,然后再对打包之后的文件进行压缩。打包命令参见:http://www.darkmi.com/blog/archives/963
命令简介
find用来查找指定目录中的文件。该命令很强大很复杂,完全掌握不是一件简单的事情,以下是几个简单示例,方便快速上手。
语法格式
find pathname -options [-print -exec -ok …]
常用参数说明
pathname:
find命令所查找的目录路径。例如用.来表示当前目录,用/来表示系统根目录。
-print:
find命令将匹配的文件输出到标准输出。
-exec:
find命令对匹配的文件执行该参数所给出的shell命令。相应命令的形式为’command’ { } \;,注意{ }和\;之间的空格。
-ok:
和-exec的作用相同,只不过以一种更为安全的模式来执行该参数所给出的shell命令,在执行每一个命令之前,都会给出提示,让用户来确定是否执行。
示例
(1)
find / -name .profile -print
从根目录开始,查找所有以.profile为后缀的文件,其中.profile既可以使用双引号也可以不使用双引号。
这是AIX的man手册中的第一个示例。假如我们要搜索当前目录下的所有以cp为后缀的文件,仿照该示例,命令应该是这个样子:
find . -name .cp -print
但是输入该命令无任何输出。可以输出当前目录所有以cp为后缀的文件的命令如下:
find . -name “*.cp” -print
(2)
find ./ -name “*.php” | xargs grep ‘要查找的内容’
查找当前目录下面所有的php文件里面的指定内容。
(3)
find ./ -name “*.php” | xargs grep -F ‘要查找的内容’
如果需要查找的内容包含特殊符号,比如$等等,grep要加参数F。
(4)
Find 如何过滤掉没有权限的目录信息?
环境 AIX 5.3
例如查找:find / -perm -4000 -user 0 -ls | grep -v “Can’t” 会有 “find: cannot chdir to : Permission denied”类似提示,如何去掉?
解答:将命令改为 find / -perm -4000 -user 0 -ls 2>/dev/null 即可。
原始链接:http://techbbs.zol.com.cn/1/85_874.html
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
从AIX上copy下来的man手册,心情好的时候读读:
Purpose
Finds files with a matching expression.
Syntax
find [ -H | -L ] Path … [ Expression ]
Description
The find command recursively searches the directory tree for each specified Path parameter, seeking files that match a Boolean expression written using the terms given in the following text. When the find command is recursively descending directory structures, it will not descend into directories that are symbolically linked into the current hierarchy. The output from the find command depends on the terms specified by the Expression parameter.
find命令会递归搜索path参数指定的目录,在其中寻找符合express所指定的boolean表达式的文件。再递归遍历的过程中,如果遇到链接到当前目录的链接符号,不会对其进行遍历。find命令的结果依赖于expression参数。
The find command does not support the 4.3 BSD fast find syntax.
Flags
-H
Cause the file information and file type evaluated for each symbolic link encountered on the command line to be those of the file referenced by the link, and not the link itself. If the referenced file does not exist, the file information and type shall be for the link itself. File information for all symbolic links not on the command line
shall be that of the link itself.-L
Cause the file information and file type evaluated for each symbolic link to be those of the file referenced by the link, and not the link itself.Expression Terms
These Boolean expressions and variables describe the search boundaries of the find command as defined in the Path and Expression parameters. Note: In the following definitions, the n variable specifies a decimal integer that can be expressed as +n (more than n), -n (less than n), or n (exactly n).
\( Expression \)
Evaluates to the value True if the expression in parentheses is true.-cpio Device
Writes the current file to the specified device in the cpio command format.-depth
Always evaluates to the value True. Causes the descent of the directory hierarchy to be done so that all entries in a directory are affected before the directory itself is affected. This can be useful when the find command is used with the cpio command to transfer files that are contained in directories without write permission.-ea
Evaluates to the value True if file has either access control information (ACL) or Extended attributes (EA) set.-exec Command
Evaluates to the value True if the specified command runs and returns a 0 value as exit status. The end of the specified command must be punctuated by a semicolon in quotation marks or escaped semicolon. A command parameter {}(braces) is replaced by the current path name.-follow
Causes symbolic and hard links to be followed.-fstype Type
Evaluates to the value True if the file system to which the file belongs is of the specified type, where the Type
variable has a value of jfs (journaled file system) or nfs (network file system).-group Group
Evaluates to the value True if the file belongs to the specified group. If the value of the Group variable is numeric
and does not appear in the /etc/group file, it is interpreted as a group ID.-nogroup
Evaluates to the value True if the file belongs to a group not in the /etc/group database.-inum n
Evaluates to the value True if file has an i-node matching the value of the n variable.-links n
Evaluates to the value True if the file has the specified number of links. See the ln command for a description of
links.-long
Prints all available characters of each user/group name instead of truncating to the first 8 when used in combination
with -ls.-ls
Always evaluates to the value True. Causes the current path name to be printed together with its associated
statistics. These statistics include the following:
* I-node number
* Size in kilobytes (1024 bytes)
* Protection mode
* Number of hard links
* User
* Group
* Size in bytes
* Modification timeIf the file is a special file, the size field contains the major and minor device numbers. If the file is a symbolic
link, the path name of the linked-to file is printed preceded by the -> (hyphen, greater than) symbols. Formatting is
similar to that of the ls -filds command, however formatting is done internally without executing the ls command,
therefore differences in output with the ls command may exist, such as with the protection mode.-name File
Evaluates to the value True if the value of the File variable matches the file name. The usual shell filename
generation characters (see the sh command) can be used. The pattern should either be enclosed in quotation marks or
the escape character used when the find command is used from the shell. A backslash ( \ ) is used as an escape
character within the pattern. You can use wildcard (pattern-matching) characters, provided they are in quotation
marks. See “Pattern Matching with Wildcards and Metacharacters” in AIX 5L Version 5.3 System User’s Guide: Operating
System and Devices for more information on using wildcard characters.In an expression such as [a-z], the hyphen means through according to the current collating sequence. A collating
sequence may define equivalence classes for use in character ranges. See “National Language Support OverviewWow” in
the AIX 5L Version 5.3 National Language Support Guide and Reference for more information on collating sequences and
equivalence classes.-newer File
Evaluates to the value True if the current file has been modified more recently than the file indicated by the File
variable.-ok Command
The same as the -exec expression, except that the find command asks you whether it should start the specified command.
An affirmative response starts the command. The end of the specified command must be punctuated by a semicolon
enclosed in quotation marks or the \; (backslash-escape semicolon).-perm [ – ] OctalNumber
Evaluates to the value True if the permission code of the file exactly matches the OctalNumber parameter (see the
chmod command for an explanation of file permissions). If the optional – (hyphen) is present, this expression
evaluates to true if at least these permissions are set. The OctalNumber parameter may be up to nine octal digits.-perm [ – ] Mode
The mode argument is used to represent file mode bits. It will be identical in format to theoperand
described in chmod, and will be interpreted as follows:Initially, a template will be assumed with all file mode bits cleared. Op symbols have the following function:
+
sets the appropriate mode bits in the template
–
clears the appropriate bits
=sets the appropriate mode bits, without regard to the contents of the process’ file mode creation mask
The op symbol – cannot be the first character of mode. This avoids ambiguity with the optional leading hyphen. Because
the initial mode is all bits off, there are no symbolic modes that need to use – as the first character.If the hyphen is omitted, the primary evaluates as True when the file permission bits exactly match the value of the
resulting template. Otherwise, if mode is prefixed by a hyphen, the primary will evaluate as True if at least all bits
in the resulting template are set in the file permission bits.The Mode parameter is identical to the chmod command syntax. This expression evaluates to the value True if the file
has exactly these permissions. If the optional – (hyphen) is present, this expression evaluates to the value True if
at least these permissions are set.
Always evaluates to the value True. Displays the current path name. The find command assumes a -print expression,
unless the -exec, – ls, or -ok expressions are present.
-prune
Always evaluates to the value True. Stops the descent of the current path name if it is a directory. If the -depth
flag is specified, the -prune flag is ignored.
-size n
Evaluates to the value True if the file is the specified n of blocks long (512 bytes per block). The file size is
rounded up to the nearest block for comparison.
-size nc
Evaluates to the value True if the file is exactly the specified n of bytes long. Adding c to the end of the n
variable indicates that the size of the file is measured in individual bytes not blocks.
-atime n
Evaluates as True if the file access time subtracted from the initialization time, divided by 86400 seconds (with any
remainder discarded), is n. 86400 seconds is 24 hours. Note: The definition of -atime has changed to comply with the
Single UNIX Specification, Version 3. The previous behavior of -atime evaluated as True if the file had been accessed
in n-1 to n multiples of 24 hours. By default, find -atime works like it did prior to UNIX03. The UNIX03 behavior can
be obtained by setting the environment variables XPG_SUS_ENV to ON and XPG_UNIX98 to OFF.The previous behavior for this option can be obtained by setting the XPG_UNIX98 variable to ON.
-ctime n
Evaluates to the value True if the file i-node (status information) has been changed in the specified number of 24-
hour periods.
-mtime n
Evaluates as True if the file modification time subtracted from the initialization time, divided by 86400 seconds
(with any remainder discarded), is n. 86400 seconds is 24 hours. Note: The definition of -mtime has changed to comply
with the Single UNIX Specification, Version 3. The previous behavior of -mtime evaluated as True if the file had been
modified in n-1 to n multiples of 24 hours. By default, find -mtime works like it did prior to UNIX03. The UNIX03
behavior can be obtained by setting the environment variables XPG_SUS_ENV to ON and XPG_UNIX98 to OFF.The previous behavior for this option can be obtained by setting the XPG_UNIX98 variable to ON.
-amin Number
Evaluates to the value True if the file has been accessed in Number-1 to Number minutes. For example, -amin 2 is true
if the file has been accessed within 1 to 2 minutes.
-cmin Number
Evaluates to the value True if the file i-node (status information) has been changed in the specified number of
minutes.
-mmin Number
Evaluates to the value True if the file has been modified in Number-1 to Number minutes
-type Type
Evaluates to the value True if the Type variable specifies one of the following values:
b
Block special file
c
Character special file
d
Directoryf
Plain file
l
Symbolic link
p
FIFO (a named pipe)
s
Socket
-user User
Evaluates to the value True if the file belongs to the specified user. If the value of the User variable is numeric
and does not appear as a login name in the /etc/passwd file, it is interpreted as a user ID.
-nouser
Evaluates to the value True if the file belongs to a user not in the /etc/passwd database.
-xdev
Always evaluates to the value True. Prevents the find command from traversing a file system different from the one
specified by the Path parameter.These expressions can be combined using the following operators in the order of decreasing precedence:
1 ( Expression ) – A parenthetic group of expressions and operators (parentheses are special to the shell and require
the backslash-escape sequence).
2 ! Expression – The negation of an expression (‘!’ is the unary NOT operator).
3 Expression [ -a ] Expression – Concatenation of expressions (the AND operation is implied by the juxtaposition of two
primaries or may be explicitly stated as -a).
4 Expression -o Expression – Alternation of primaries; -o is the OR operator. The second expression will not be
evaluated if the first expression is true. Note: When using the find and cpio commands together, you must use the
-follow option with the cpio command when using the -L option with the cpio command, and visa versa. Not using these
two options together produces undesirable results. If no expression is present, -print as used in the default
expression. For example, if the given expression does not contain any of the primaries -exec, -ok, or -print, the
given expression will be replaced by (given_expression) -print. The -user, -group, and -newer primaries each evaluate
their respective arguments only once. Using a command specified by -exec or -ok does not affect subsequent primaries
on the same file.Exit Status
This command returns the following exit values:
0
All Path parameters were traversed successfully.
>0
An error occurred.Examples
1、To list all files in the file system with a given base file name, type: find / -name .profile -print
This searches the entire file system and writes the complete path names of all files named .profile. The / (slash) tells the find command to search the root directory and all of its subdirectories. In order not to waste time, it is best to limit the search by specifying the directories where you think the files might be.
1、列出文件系统中指定后缀的所有文件使用如下命令:find / -name .profile -print
该命令会从根路径开始,搜索整个文件系统并输出后缀名为.profile的所有文件的完整路径。/(正斜杠)表示从根路径开始搜索整个文件系统。为了提高搜索的效率,最好指定一个搜索文件可能存在的文件夹,为find命令缩小搜索的范围。
2 To list files having a specific permission code in the current directory tree, type: find . -perm 0600 -print
This lists the names of the files that have only owner-read and owner-write permission. The . (dot) tells the find command to search the current directory and its subdirectories. See the chmod command for an explanation of permission codes.
3 To search several directories for files with certain permission codes, type: find manual clients proposals -perm -0600 -print
This lists the names of the files that have owner-read and owner-write permission and possibly other permissions. The manual, clients, and proposals directories and their subdirectories are searched. In the previous example, -perm 0600 selects only files with permission codes that match 0600 exactly. In this example, -perm -0600 selects files with permission codes that allow the accesses indicated by 0600 and other accesses above the 0600 level. This also matches
the permission codes 0622 and 2744.4 To list all files in the current directory that have been changed during the current 24-hour period, type: find .-ctime 1 -print
5 To search for regular files with multiple links, type: find . -type f -links +1 -print
This lists the names of the ordinary files (-type f) that have more than one link (-links +1). Note: Every directory
has at least two links: the entry in its parent directory and its own . (dot) entry. The ln command explains multiple
file links.6 To find all accessible files whose path name contains find, type: find . -name ‘*find*’ -print
7 To remove all files named a.out or *.o that have not been accessed for a week and that are not mounted using nfs,
type: find / \( -name a.out -o -name ‘*.o’ \) -atime +7 ! -fstype nfs -exec rm {} \;Note: The number used within the -atime expression is +7. This is the correct entry if you want the command to act on
files not accessed for more than a week (seven 24-hour periods).8 To print the path names of all files in or below the current directory, except the directories named SCCS or files in
the SCCS directories, type: find . -name SCCS -prune -o -printTo print the path names of all files in or below the current directory, including the names of SCCS directories, type:
find . -print -name SCCS -prune
9 To search for all files that are exactly 414 bytes long, type:
find . -size 414c -print
10 To find and remove every file in your home directory with the .c suffix, type:find /u/arnold -name “*.c” -exec rm {} \;
Every time the find command identifies a file with the .c suffix, the rm command deletes that file. The rm command is
the only parameter specified for the -exec expression. The {} (braces) represent the current path name.
11 In this example, dirlink is a symbolic link to the directory dir. You can list the files in dir by refering to the
symbolic link dirlink on the command line. To do this, type:find -H dirlink -print
12 In this example, dirlink is a symbolic link to the directory dir. To list the files in dirlink, traversing the file
hierarchy under dir including any symbolic links, type:find -L dirlink -print
13 To determine whether the file dir1 referred by the symbolic link dirlink is newer than dir2, type:find -H dirlink -newer dir2
Note: Because the -H flag is used, time data is collected not from dirlink but instead from dir1, which is found by
traversing the symbolic link.
14 To produce a listing of files in the current directory in ls format with expanded user and group name, type :find . -ls -long
15 To list the files with ACL/EA set in current directory, type:find . -ea
Files
/usr/bin/find
Contains the find command.
/bin/find
Symbolic link to the find command.
/etc/group
Contains a list of all known groups./etc/passwd
Contains a list of all known users.Related Information
The chmod command, cpio command, ln command, sh command.
Backup Overview for System Management in AIX 5L Version 5.3 System Management Concepts: Operating System and Devices
introduces archiving methods, including the use of the cpio command.Directories Overview in AIX 5L Version 5.3 Files Reference describes the structure and characteristics of directories in
the file system.Types of Files in AIX 5L Version 5.3 System User’s Guide: Operating System and Devices describes files, file types, how to
name files, and how to use wildcard characters.Input and Output Redirection Overview in AIX 5L Version 5.3 System User’s Guide: Operating System and Devices describes how
the operating system processes input and output.Shells Overview in AIX 5L Version 5.3 System User’s Guide: Operating System and Devices describes shells, the different
types of shells, and how shells affect the way commands are interpreted.File and Directory Access Modes in AIX 5L Version 5.3 System User’s Guide: Operating System and Devices introduces file
ownership and permissions to access files and directories.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
参考链接:
Linux文件查找命令find,xargs详述
http://blog.csdn.net/ydfok/archive/2007/01/18/1486451.aspx
comm(common)
功能说明
这项指令会一列列地比较两个已排序文档的差异,并将其结果显示出来,假如没有指定任何参数,则会把结果分成3行显示:第1行仅是在第1个文档中出现过的列,第2行是仅在第2个文档中出现过的列,第3行则是在第1和第2个文档里都出现过的列。若给予的文档名称为”-“,则comm指令会从标准输入设备读取数据。
语法
comm [-123][–help][–version][第1个文档][第2个文档]
参数
-1:不显示只在第1个文档里出现过的列。
-2:不显示只在第2个文档里出现过的列。
-3:不显示只在第1和第2个文档里出现过的列。
–help 在线帮助。
–version 显示版本信息。
示例
a.txt的内容如下:
[160]/boss18/work/mixh/test/>cat a.txt
aaaa
bbbb
cccc
eeee
ffff
b.txt的内容如下:
[160]/boss18/work/mixh/test/>cat b.txt
aaaa
bbbb
cccc
dddd
ffff
比较的结果如下:
[160]/boss18/work/mixh/test/>comm a.txt b.txt
++++++++aaaa
++++++++bbbb
++++++++cccc
++++dddd
eeee++++++++
++++++++ffff
cmp
功能说明
cmp(“compare”的缩写)命令用来简要指出两个文档是否存在差异,他的使用权限是任何用户。
语法
cmp[options] 文档名
[options]主要参数
-l: 将字节以十进制的方式输出,并方便将两个文档中不同的以八进制的方式输出。
同样的两个文件cmp的输出如下:
[160]/boss18/work/mixh/test/>cmp a.txt b.txt
a.txt b.txt differ: char 16, line 4
diff
功能说明
diff命令用于两个文档之间的比较,并指出两者的不同,他的使用权限是任何用户。
语法
diff [options] 源文档 目标文档
参数
-a:将任何文档当作文本文档来处理。
-b:忽略空格造成的不同。
-B:忽略空行造成的不同。
-c:使用纲要输出格式。
-H:利用试探法加速对大文档的搜索。
-I:忽略大小写的变化。
-n –rcs:输出RCS格式。
同样的两个文件,diff命令的输出如下:
[160]/boss18/work/mixh/test/>diff a.txt b.txt
4c4
< eeee
---
> dddd
[160]/boss18/work/mixh/test/>
更改个人使用资料:
1. passwd
passwd 是用来更改你的使用密码,用法为:
passwd [ username ]
在使用 passwd 的时候,它会先问你的旧密码,然后询问两次要更改的密码,确定
无误后才将你的密码改掉。
2. chsh
chsh 是提供使用者更换 login shell 的指令,你可经由此更换自己使用的 shell 。