`
textboy
  • 浏览: 20351 次
  • 性别: Icon_minigender_1
  • 来自: 广州
最近访客 更多访客>>
社区版块
存档分类
最新评论
阅读更多

1.1         df

 

Check available disk space.

 

Syntax             df [-k] [directory]

         df [-t] [-x] [-k] [-p] [-a] ... [filename]

 

Option or argument

Function

-g

Displays statistics in units of GB blocks

-k

Displays only the amount of free space in kilobytes.

-v

Displays all information for the specified file system.

Directory

Displays space on the file system where that directory resides.

 

The df listing includes lots of information about each file system (logical disk or disk partition) to which you have access, including its total size, the amount of space that’s full (used), the free space, the percentage that’s full (capacity), and, if it’s a network file system, on which file server it is.

 

Sample:

 

You are wondering how much space is on the disk on which your home directory is stored. Assuming that your username is ysg, type

 

df /home/ysg

 

e.g. fr wing: df –gv|grep bcn; df -gv ./; df –h ./ (for solaris)

1.2         diff

 

Compares two files and prints the lines in which the files differ, for ascII files. Refer cmp.

 

Syntax             diff [-b] [-i][-w] filename1 filename2

  or

         diff [-b] [-i][-w] filename1 directory1

  or

         diff [-b] [-i][-r][-w] directory1 directory2

 

Option or argument

Function

-b

Treats groups of spaces (blanks) as single spaces, so it ignores spacing differences.

-i

Ignores the difference between uppercase and lowercase letters.

-r

When you’re comparing two directories, specifies that subdirectories should be compared, too.

-w

Ignores all spaces and tabs.

filename1

Specifies one file to compare.

filename2

Specifies the other file to compare.

directory1

Specifies one directory to compare. If you tell diff to compare a file to a directory, it looks in the directory for a file of the same name and compares the two files

directory2

Specifies the other directory to compare. If you tell diff to compare two directories, it looks in both directories for files of the same name and compares all pairs of files with the same names. It also lists the names of files that are in one directory but not in the other.

 

1.3         du

Check disk space usage.

Syntax      du [-a] [-b] [-c] [-D] [-k] [-l] [-L] [-s] [-S] [-x] [filename]

 

1.4         echo

e.g.

echo $HOME

 

1.5         egrep

Searches a file for a pattern.

e.g.

egrep "\(([A-z]+|[0-9]+)\)" my.txt

 

1.6         exec

Refer &.

 

1.7         expr

Compute.

e.g.

Asterisk & Parentheses

expr \( 11 + 5 \) '*' 2

 

1.8         find

 

Finds one or more files based on rules your give, and does something to them.refer whereis.

 

Syntax             find directory [-name filename] [-user username] [-print]

 

Option or argument

Function

directory

Specifies a list of directories in which you want to begin the search. The find command searches all the subdirectories of these directories, too. If you want to start in the current directory, just type a single period(.).

-name filename

Specifies the name of the file (or files) you want to find. If you don’t know the exact name, you can use the wildcard characters ? and *.A? stands for any single character, and a * stands for a group of characters. You must quote the filename if you use wildcards.

-user username

Specifies the user who owns the files you want to find.

-print

Displays the names of files it finds. If you don’t include this option, the find command may find lots of files, but it doesn’t tell you about them.

-type f

Check if plain file, vice versa ‘–type d’ check if directory

 

 

Sample:

 

If you want to look in several places for a file, you can type several directories on the command line, like this:

 

find . /home/john –name chapter3 -print

The . (dot) tells the find command to search the current directory and its subdirectories.

 

To search for all the files you own (assuming that your username is stuart), type

 

find / -user stuart -print

The / (slash) tells the find command to search the root directory and all of its subdirectories.

 

find /hsbc/rlse_bcn/objects -type f | xargs rm

Delete all the files in this folder

find /hsbc/rlse_bcn/objects -type f -exec rm

the problem with this approach is that each time find matches a file, it invokes rm, which is a very resource-intensive strategy.

 

find ./ -type f -name "*axmh*"

find ./ -type d -name "folder"

 

1.9         finger

 

Lists the people using your computer – with their real names, not just their UNIX usernames.

 

Syntax             finger [username]

  or

         finger [@hostname]

  or

         finger [username@hostname]

 

Option or argument

Function

username

Specifies the user (or users) about whom you want more information.

hostname

Specifies the hostname of the computer about which you want information.

See also who.

 

Sample:

 

You wonder who else is using your computer. Type:

 

finger

 

To find more information about a user andrewg, type

 

finger andrewg

 

1.10     ftp

use like in DOS. Can use command like lcd / cd / put / get.

1.11     get

ftp to local host, refer put.

 

1.12     getfacl (solaris)

show access control, similar with aclget in AIX.

 

1.13     grep

 

Finds lines in one or more files that contain a particular word or phrase.

To prevent regular expressions is interpreted as wildcards, it is better to surround the regular expression with single quotes ( ' ).

Complex expression try egrep.

Search for multiple patterns at once try fgrep.

 

Syntax             grep [-i] [-l] [-n] [-v] text  filenames

 

Option or argument

Function

-E

-E flag is the same as the egrep command, except that error and usage messages are different and the -s flag functions differently.

-i

Ignores case (uppercase and lowercase) when you’re searching.

-l

Displays only the names of the files that contain the text, not the actual lines.

-n

Displays the line numbers that contain the text.

-p[Separator]

Displays the entire paragraph containing matched lines. Paragraphs are delimited by paragraph separators.

-s

Display only error message for checking.

-v

Specifies that you’re looking for lines that don’t contain the text.

text

Specifies the word or phrase to search for. If the text includes spaces or punctuation that may confuse AIX, enclose it in quotation marks.

filenames

Specifies the file(s) in which to search; to search all the files in the current directory, type * (asterisk).

 

e.g.

 

You are looking for the memo you wrote in which you mentioned microwaveable shelf-stable foods. To search all the files in the current directory, type:

 

grep “mentioned microwaveable shelf-stable” *

 

if you don’t find the file you want. You realize that the M might be capitalized, so you tell grep to ignore capitalization by typing:

 

grep –i “mentioned microwaveable shelf-stable” *

grep -n IBISCMB *.sql

 

grep -B1 -A1 "tty" /etc/passwd

display the context.

 

grep “^[a-zA-Z]” pgm.s

 

Regular Express: grep -E "MatnJobQ|UserJob"

 

find ./ -type f -name "*axmh*" | xargs grep -il "a2mh"

ls -l | grep ^d

 

分享到:
评论

相关推荐

    CMDCMD命令CMD命令

    14. `tlist` 和 `kill`:这两个命令是用于查看和结束进程的,通常在系统调试和故障排除中使用。 15. `del` 和 `move`:文件管理命令,`del`用于删除文件,`/S /Q`选项可以递归删除目录及其内容而不提示,`move`用于...

    cmd管道技术向cmd发送字符

    如`dir /b | sort > list.txt` 会排序目录中的文件并保存到`list.txt`,然后可以使用`fc /l list.txt list_sorted.txt` 比较排序前后的差异。 3. **统计分析**:`find`命令可以计数特定字符或字符串。如`type file....

    java javascript 调用命令行 cmd

    List<String> commands = Arrays.asList("cmd", "/c", "dir"); ProcessBuilder pb = new ProcessBuilder(commands); Process process = pb.start(); ``` **JavaScript调用命令行** 在JavaScript中,由于安全...

    sqlcmd 参数详解

    * -k [ 1 | 2 ] remove [ replace ] control characters:删除或替换控制字符。 八、其他选项 * -y display_width:指定显示宽度。 * -Y display_width:指定显示宽度。 * -b on error batch abort:在错误时中止...

    CMD网络命令大全123

    ##### 2. **`net user`** - **创建用户**: ```cmd net user 用户名 密码 add ``` 创建一个新的用户账户,并设置初始密码。 - **激活 guest 用户**: ```cmd net user guest active yes ``` 激活guest...

    Qt调用CMD启动外部程序Demo.zip

    process->start("cmd.exe", QStringList() ); ``` 这里,`"/c"`参数告诉CMD执行完`notepad.exe`后关闭,`notepad.exe`则是我们要启动的外部程序。 接下来,我们关注如何处理子进程的输出。QProcess提供了`...

    qt调用cmd命令和dll例子

    process.start("cmd.exe", QStringList() ); process.waitForFinished(); ``` 这里的`start`方法启动了CMD进程,并通过`/c`参数传递了执行"dir"命令的指令。`waitForFinished`确保我们等待命令执行完成后再继续执行...

    linux 离线安装perl-IPC-Cmd

    2. `perl-Test-Harness-3.28-3.el7.noarch.rpm`: 提供了测试框架,用于编写和运行Perl模块的测试套件。 3. `perl-ExtUtils-MakeMaker-6.68-3.el7.noarch.rpm`: 是Perl模块构建工具,用于创建Makefile,帮助开发者...

    cmd中的重定向输出,管道

    在CMD中,标准输出通常使用数字`1`表示,而标准错误输出则使用数字`2`表示。通过使用`2>&1`,我们可以将标准错误输出重定向到标准输出,从而将两者合并为一个输出流。例如: ```cmd mycommand > mylog.txt 2>&1 ```...

    C# 传入自定义列表List 到Oracle存储过程

    OracleParameter param = cmd.Parameters.Add("return_value", OracleDbType.Varchar2, ParameterDirection.ReturnValue); param.ArrayBindSize = myList.Count; param.CollectionType = OracleCollectionType....

    静态编译的trace-cmd,x86版本,v3.1.4

    2. **事件选择**: `trace-cmd list`可以列出所有可用的内核事件,用户可以根据需求选择要追踪的事件。 3. **查看日志**: `trace-cmd report`命令将追踪数据转化为可读的报告,帮助分析系统行为。 4. **保存/加载**...

    遍历CheckBoxList,获得选中项的值动态绑定CheckBoxList代码

    ### 遍历CheckBoxList,获得选中项的值动态绑定CheckBoxList #### 知识点一:CheckBoxList概述及应用场景 **CheckBoxList** 是ASP.NET Web Forms中一个非常有用的控件,它允许用户选择一个或多个选项。CheckBoxList...

    java调用cmd创建目录和复制文件

    2. Windows CMD的`mkdir`和`copy`命令 3. 异常处理和错误检查 4. 操作系统兼容性考虑 5. 安全编码实践 在实际项目中,如果频繁进行此类操作,建议使用Java的I/O和NIO库,或者第三方库如Apache Commons IO,它们提供...

    常用的一些cmd命令

    #### 2. **用户账户管理** - `net user`:用于添加、修改或查看用户账户信息。 - `net user û /add`:创建新用户û。 - `net user guest /active:yes`:激活Guest账户。 - `net user ʻ`:显示所有用户列表。 ...

    cmd应用大全,经典不容错过

    - `tlist -t` 列出系统中的所有进程,`kill -F 进程名` 强制结束进程(需要安装额外工具)。 5. **文件操作**: - `del` 命令用于删除文件,`del /F 文件名` 可删除只读文件,`del /S /Q 目录` 删除指定目录下的...

    Linux系统firewall-cmd 命令详解.docx

    * firewall-cmd --zone=dmz --list-ports 这将显示 dmz zone 中所有打开的端口。 firewall-cmd 命令还可以用于添加端口到 zone,例如: * firewall-cmd --zone=dmz --add-port=8080/tcp 这将添加 8080 端口到 ...

    CMD快速操作

    2. **用户与组管理**: - `net user`:创建、查看或修改用户账户。`net user guest /active:yes`激活guest用户。 - `net localgroup`:管理本地组,如将用户添加到管理员组。 3. **服务管理**: - `net pause` ...

    CMD命令(自己的收藏啊)

    16. `tlist -t`和`kill -F`: 分别用于列出和结束进程,通常在Support Tools中。 17. `del`和`rmdir`: 用于删除文件和目录,`-F`选项可删除只读文件,`/S`和`/Q`分别用于删除目录及其内容,且不提示确认。 18. `...

    CMD常用命令.txt

    ### CMD常用命令解析 #### 一、Ping命令详解 **命令格式:** ``` ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS] [[-r count] | [-s count]] [-j computer-list | -k computer-list] [-w timeout] ...

Global site tag (gtag.js) - Google Analytics