zoukankan      html  css  js  c++  java
  • Chap5:操作文件和目录[The Linux Command Line]

    Wildcards
    WildcardMeaning
    * Matches any characters
    ? Matches any single character
    [characters] Matches any character that is a member of the set characters
    [!characters] Matches any character that is not a member of the set characters
    [[:class:]] Matches any character that is a member of the specified class
    Commonly Used Character Classes
    Character ClassMeaning
    [:alnum:] Matches any alphanumeric character
    [:alpha:] Matches any alphabetic character
    [:digit:] Matches any numeral
    [:lower:] Matches any lowercase letter
    [:upper:] Matches any uppercase letter
    Wildcard Examples
    PatternMatches
    * All files
    g* All file beginning with "g"
    b*.txt Any file beginning with "b" followed by any characters and ending with ".txt"
    Data??? Any file beginning with "Data" followed by exactly three characters
    [abc]* Any file beginning with either an "a", a "b", or a "c"
    BACKUP.[0-9][0-9][0-9] Any file beginning with "BACKUP." followed by exactly three numerals
    [[:upper:]]* Any file beginning with an uppercase letter
    [![:digit:]]* Any file not beginning with a numeral
    *[[:lower:]123] Any file ending with a lowercase letter or the numerals "1", "2", or "3"

    cp-Copy files and directories

    cp Options
    OptionMeaning
    -a, --archive Copy the files and directories and all of their attributes, including ownerships and permissions. Normally, copies take on the default attributes of the user performing the copy
    -i, --interactive Before overwriting an existing file, prompt the user for confirmation. If this option is not specified, cp will silently overwrite files.
    -r, --recursive Recursively copy directories and their contents. This option (or the -a option) is required when copying directories.
    -u, --update When copying files from one directory to another, only copy files that either don't exist, or are newer than the existing corresponding files, in the destination directory.
    -v, --verbose Display informative messages as the copy is performed.
    cp Examples
    CommandResults
    cp file1 file2 Copy file1 to file2. If file2 exists, it is overwritten with the contents of file1. If file2 does not exist, it is created.
    cp -i file1 file2 Same as above, except that if file2 exists, the user is prompted before it is overwritten.
    cp file1 file2 dir1 Copy file1 and file2 into directory dir1. dir1 must already exist.
    cp dir1/* dir2 Using a wildcard, all the files in dir1 are copied into dir2. dir2 must already exist.
    cp -r dir1 dir2 Copy the contents of directory dir1 to directory dir2. If directory dir2 does not exist, it is created and, after the copy, will contain the same contents as directory dir1. If directory dir2 does exist, then directory dir1 (and its contents) will be copied into dir2.

    mv-Move/rename files and directories

    mv options
    OptionMeaning
    -i --interactive Before overwriting an existing file, prompt the user for confirmation. If this option is not specified, mv command will silently overwrite files
    -u --update When moving files from one directory to another, only move files that either don't exist, or are newer than the existing corresponding files in the destination directory.
    -v --verbose Display informative messages as the move is performed.
    mv Examples
    mv file1 file2 Move file1 to file2. If file2 exists, it is overwritten with the contents of files. If file2 does not exist, it is created. In either case, file1 ceases to exist.
    mv -i file1 file2 Same as above, except that if file2 exists, the user is prompted before it is overwritten.
    mv file1 file2 dir1 Move file1 and file2 into dirctory dir1. dir1 must already exist.
    mv dir1 dir2 if directory dir2 does not exist, create directory dir2 and move the contents of directory dir1 into dir2 and delete directory dir1. if directory dir2 does exist, move directory dir1 (and its contents) into directory dir2.

    mkdir-Create directories

    rm Options
    OptionMeaning
    -i, --interactive Before deleting an existing file, prompt the user for confirmation. If this option is not specified, rm will silently delete files.
    -r, --recursive Recursively delete directories. This means that if a directory being deleted has subdirectories, delete them too. To delete a directory, this option must be specified.
    -f, --force Ignore nonexistent files and do not prompt. This overrides the --interactive option.
    -v, --verbose Display informative messages as the deletion is performed.
    rm Examples
    CommandResults
    rm file1 Delete file1 silently
    rm -i file1 Same as above, except that the user is prompted for confirmation before the deletion is performed.
    rm -r file1 dir1 Delete file1 and dir1 and its contents.
    rm -rf file1 dir1 Same as above, except that if either file1 or dir1 do not exist, rm will continue silently.

    rm-Remove files and directories

    ln-Create hard and symbolic links

  • 相关阅读:
    机器学习-数据与特征工程
    机器学习-聚类(clustering)算法:K-means算法
    机器学习-回归中的相关度和R平方值
    机器学习-非线性回归(Logistic Regression)及应用
    机器学习-多元线性回归(一)
    机器学习-简单线性回归(二)
    MVC,MVP,MVVM
    Git从入门到熟练
    NSNotificationCenter
    FMDB的线程安全
  • 原文地址:https://www.cnblogs.com/ERFishing/p/10165722.html
Copyright © 2011-2022 走看看