The Find,vim of Linux commands

Source: Internet
Author: User

  • Findis the most common and powerful find command, you can use it to find any file you want to find.
    Find uses the following format:
    Find < Specify directory > < specify conditions > < specify Actions >
    -< specified directory;: the directory to be searched and all its subdirectories. The current directory is assumed by default.
    -< specified conditions;: The characteristics of the file to be searched.
    -< specify actions;: Specific processing of search results.
    [[email protected]/]# find. -name ' bin* ' finds all files in the current directory that begin with bin
    ./etc/binfmt.d
    ./etc/selinux/targeted/modules/active/modules/bind.pp
    [[email protected]/]# find. -name ' bin* '-ls find all files in the current directory that begin with bin and list file information
    You can also specify multiple start directories in the search string. If you are running as a user with the appropriate permissions, the following command finds all jar files down to the/usr,/home/tmp directory:
    Find/usr/home/tmp-name "*.jar"
    [[email protected]/]# find. -type D-type Develop the type of file to search for
    Other file types that find can be found include:
    B-Block (cache) Special
    C-character (not cached) special
    P-Named pipes (FIFO)
    S-Socket

    Find time
    The Find command has several options for searching files based on your system's timestamp. These timestamps include
    mtime-file content Last modified
    The time that the atime-file was read or accessed
    ctime-File Status Change time
    The meaning of Mtime and atime is easy to understand, and ctime needs more explanations. Because the inode maintains the metadata on each file, the Inode data also changes if the file-related metadata changes. This can be caused by a series of actions, including creating symbolic links to files, changing file permissions, or moving files. Because in these cases, the contents of the file are not read or modified, so mtime and atime do not change, but CTime will change.
    These time options need to be used in conjunction with a value of n, specified as-n, N, or +n.
    -N return item less than n
    +n return item greater than n
    N returns an item exactly equal to n

    [[email protected]/]# find/etc-mtime-1//View files modified in/etc directory within one hours
    /etc
    /etc/resolv.conf
    /etc/tuned/active_profile
    /etc/sysconfig
    /etc/sysconfig/network-scripts
    Find files by size
    The-size option finds files that meet the specified size criteria.
    [[email protected]/]# find/etc-size-1k//view files in/etc directory size less than 1k
    /etc/crypttab
    /etc/motd
    /etc/cron.deny
    /etc/.pwd.lock
    /etc/environment
    /etc/sysconfig/run-parts
    /etc/selinux/targeted/modules/semanage.read.lock
    /etc/selinux/targeted/modules/active/netfilter_contexts
    /etc/selinux/targeted/modules/semanage.trans.lock
    /etc/selinux/targeted/contexts/files/file_contexts.local
    /etc/selinux/targeted/contexts/files/file_contexts.subs
    /etc/security/opasswd
    /etc/exports
    [[email protected]/]# find/etc-empty//-empty empty file
    /etc/terminfo
    /etc/systemd/user
    /etc/gnupg
    /etc/crypttab
    /etc/opt
    /etc/motd
    /etc/gcrypt
    /etc/ppp/peers
    /etc/chkconfig.d
    /etc/rwtab.d
    /etc/groff/site-font
    /etc/firewalld/services
    /etc/firewalld/icmptypes

    Find by permissions and owners
    Find. -type f-perm a=rwx-exec ls-l {} \;
    [Email protected]/]# find/etc-perm 777-exec ls-l {} \; -perm View by permissions
    lrwxrwxrwx. 1 root root 03:07/etc/systemd/system/getty.target.wants/[email protected]-/usr/lib/systemd/system/[ Email protected]
    lrwxrwxrwx. 1 root root 03:08/etc/systemd/system/dbus-org.fedoraproject.firewalld1.service/usr/lib/systemd/system /firewalld.service
    lrwxrwxrwx. 1 root root 03:08/etc/systemd/system/dbus-org.freedesktop.networkmanager.service/usr/lib/systemd/ System/networkmanager.service

    [Email protected]/]# find/etc/-perm u=rwx-exec ls-l {} \; View files based on owner's permissions
    -RWX------. 1 root root 2013/etc/cron.daily/logrotate
    Total 0
    Total 0
    Total 68
    -rwxr-xr-x. 1 root root 8702 Mar 16:27 00_header
    -rwxr-xr-x. 1 root root 992 Oct 00_tuned
    -rwxr-xr-x. 1 root root 10114 Mar 16:27 10_linux
    -rwxr-xr-x. 1 root root 10275 Mar 16:27 20_linux_xen
    -rwxr-xr-x. 1 root root 2559 Mar 16:27 20_ppc_terminfo
    -rwxr-xr-x. 1 root root 11169 Mar 16:27 30_os-prober
    -rwxr-xr-x. 1 root root 214 Mar 16:27 40_custom
    -rwxr-xr-x. 1 root root 216 Mar 16:27 41_custom
    -rw-r--r--. 1 root root 483 Mar 16:27 README
    [Email protected]/]# find/etc/-perm u=rwx-exec ls-l {} \; 2>/dev/null//Add error redirection

    Control find
    Unlike many commands in Linux, find does not need the-R or-r option to go down to subdirectories. This is done by default. However, there are times when you might want to limit this behavior. As a result, options-depth,-maxdepth, and-mindepth, as well as operational-prune, are handy.
    The-maxdepth and-mindepth options allow you to specify which level of the directory tree you want the find search to drill down to. You can see the effect of-maxdepth by running the following command to find the log file in the top three levels of the directory tree. Using this option is much less than the output generated by not using this option.
    [[email protected]/]# Find/-maxdepth 3-name ' *.log '
    /tmp/yum.log
    /var/log/boot.log
    /var/log/yum.log


  • Vim -->vi improved

    vim [options] [file] ...
    Mode switching
    Default to edit mode
    Edit mode--Input mode
    I: Where the cursor is currently located
    I: At the beginning of the line where the cursor is currently
    A: The character behind the cursor
    A: At the end of the line where the current cursor is located
    O: New at the bottom of your current row
    O: New at the top of the current row
    Last-line mode:
    : q! Force exit
    : Wq Save Exit
    : X Save exit
    : wq! Force Save exit
    : ZZ Save Exit
    Edit mode: CC Deletes the line of the cursor and enters insert mode
    C Delete the character after the cursor
    Visualization mode
    V: Select content on the left side of the line where the cursor is located
    V: The entire row of the cursor is selected
    Flip Screen command for edit mode
    CTRL+F: Flip a screen to the end of the file
    CTRL+B: Flip a screen to the file header
    Text Lookup
    /word
    ? word

    Address delimitation Startline, EndLine #: Nth row.: Current line $: Last line%: Full text
    Relative delimitation: +#: N rows down from the specified position-#: up n rows from the specified position
    Text substitution operations
    s/to find content/content/modifiers to replace
    /: separators such as #,@
    G: Global Substitution
    I: Case insensitive
    What to look for: You can use regular expressions
    What to replace: You cannot use regular expressions
    Interface Display Features
    Syntax highlighting open and close:
    : Syntax on/off
    Search for highlighted turns on and off:
    : Set Hlsearch
    : Set Nohlsearch
    Auto Indent
    : Set Autoindent
    : Set Noautoindent
    Vim Global configuration file/ETC/VIMRC

This article is from the "laoli110" blog, make sure to keep this source http://laoli110.blog.51cto.com/9136611/1690411

The Find,vim of Linux commands

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.