mowatermelon / learn-es6

一个有趣的人写的有趣的前端基础
http://blog.iiwhy.cn/learn-es6
7 stars 5 forks source link

learn-mac-order #118

Open mowatermelon opened 3 years ago

mowatermelon commented 3 years ago

split 指令学习

基础介绍

$ split [-a suffix_length] [-b byte_count[k|m]] [-l line_count] [-p pattern] [file [name]]

$ split -a 2 -b 1024m xx.mp4 xxsplit

$ split -a 5 -b 1024m 拉钩大前端训练营.mp4 xxsplit

按照固定行数或者估计大小分割单个文件,分割完成是没有后缀名的

ls -la
total 26070672
drwxr-xr-x  22 eva  admin         704  1 18 15:19 .
drwxr-xr-x  28 eva  admin         896  1 15 12:58 ..
-rw-r--r--@  1 eva  admin       12292  1 18 15:18 .DS_Store
-rw-r--r--   1 eva  admin  1073741824  1 18 15:19 xxsplitaa
-rw-r--r--   1 eva  admin  1073741824  1 18 15:19 xxsplitaaaaa
-rw-r--r--   1 eva  admin  1073741824  1 18 15:19 xxsplitaaaab
-rw-r--r--   1 eva  admin  1073741824  1 18 15:19 xxsplitaaaac
-rw-r--r--   1 eva  admin  1073741824  1 18 15:19 xxsplitaaaad
-rw-r--r--   1 eva  admin   147749279  1 18 15:19 xxsplitaaaae
-rw-r--r--@  1 eva  admin  4442716575  1 15 00:12 xx.mp4

参数说明

参数表格

参数名 参数值说明 中文含义 参数值举例
a suffix_length 分割默认自增长的序号后缀长度,默认值是 2 5
b byte_count[k or m]] 按照字节大小分割文件,支持 k (KB) 和 m(MB) 两个单位 1024m
l line_count 按照文件行数分割文件 1000
p pattern 满足正则验证的文件才进行分割,注意如果使用 -l 参数,这个参数不起效果
file 待分割的文件名 xxx.mp4
name 分割之后的默认的文件名前缀,默认为原文件名 xxxsplit

比较可惜的是 Linux 下,还支持 -d 让后缀默认按照数字格式进行增长,Mac 上没有

通过 man split 进入说明,按 q 键直接退出

$ man split
SPLIT(1)                  BSD General Commands Manual                 SPLIT(1)

NAME
     split -- split a file into pieces

SYNOPSIS
     split [-a suffix_length] [-b byte_count[k|m]] [-l line_count] [-p pattern] [file [name]]

DESCRIPTION
     The split utility reads the given file and breaks it up into files of 1000 lines each.  If file is a single dash (`-') or absent, split reads from the standard input.

     The options are as follows:

     -a suffix_length
             Use suffix_length letters to form the suffix of the file name.

     -b byte_count[k|m]
             Create smaller files byte_count bytes in length.  If ``k'' is appended to the number, the file is split into byte_count kilobyte pieces.  If ``m'' is appended to the number, the file is split into byte_count megabyte pieces.

     -l line_count
             Create smaller files n lines in length.

     -p pattern
             The file is split whenever an input line matches pattern, which is interpreted as an extended regular expression.  The matching line will be the first line of the next output file.  This option is incompatible with the -b and -l options.

     If additional arguments are specified, the first is used as the name of the input file which is to be split.  If a second additional argument is specified, it is used as a prefix for the names of the files into which the file is split.  In this case, each
     file into which the file is split is named by the prefix followed by a lexically ordered suffix using suffix_length characters in the range ``a-z''.  If -a is not specified, two letters are used as the suffix.

     If the name argument is not specified, the file is split into lexically ordered files named with the prefix ``x'' and with suffixes as above.

ENVIRONMENT
     The LANG, LC_ALL, LC_CTYPE and LC_COLLATE environment variables affect the execution of split as described in environ(7).

EXIT STATUS
     The split utility exits 0 on success, and >0 if an error occurs.

SEE ALSO
     csplit(1), re_format(7)

STANDARDS
     The split utility conforms to IEEE Std 1003.1-2001 (``POSIX.1'').

HISTORY
     A split command appeared in Version 3 AT&T UNIX.

BUGS
     The maximum line length for matching patterns is 65536.

BSD                             August 21, 2005                            BSD

mowatermelon commented 3 years ago

cat 指令学习

基础介绍

$  cat [-benstuv] [file ...]

$ cat xxsplit*>xx.mp4 && ls | grep xx
xx.mp4
xxsplitaaaaa.mp4
xxsplitaaaab.mp4
xxsplitaaaac.mp4
xxsplitaaaad.mp4
xxsplitaaaae.mp4

将符合条件的文件进行合并输出


参数说明

参数表格

参数名 参数值说明 中文含义
b Number the non-blank output lines, starting at 1. 在文件第一列,添加合并内容在原文件中的行索引
e Display non-printing characters (see the -v option), and display a dollar sign ($') at the end of each line.|添加$`换行符做为换行符
n Number the output lines, starting at 1. 在文件第一列,添加合并内容在合并文件中的行索引
s Squeeze multiple adjacent empty lines, causing the output to be single spaced. 除掉连续的空行,调整为单行空行
t Display non-printing characters (see the -v option), and display tab characters as ^I'.|显示tab 占位为^I'.
u Disable output buffering.
v Display non-printing characters so they are visible. Control characters print as ^X' for control-X; the delete character (octal 0177) prints as^?'. Non-ASCII characters (with the high bit set) are printed as `M-' (for meta) followed by the character for the low 7 bits. 显示默认不占位显示的字符

添加原文件行索引的效果

 28 12
    29  9
    30  4
    31  5
     1  1
     2  2
     3  34
     4  4
     5  5
     6  6
     7  7
     8  8
     9  9
    10  0
    11  12
    12  35

添加e换行符的效果

1$
2$
34$
4$
5$
6$
7$
8$
9$
0$
12$
35$

添加合并文件行索引的效果

 32 12
    33  9
    34  4
    35  5
     1  1
     2  2
     3  34
     4  4
     5  5
     6  6
     7  7
     8  8
     9  9
    10  0

通过 man cat 进入说明,按 q 键直接退出

$ man cat

CAT(1)                    BSD General Commands Manual                   CAT(1)

NAME
     cat -- concatenate and print files

SYNOPSIS
     cat [-benstuv] [file ...]

DESCRIPTION
     The cat utility reads files sequentially, writing them to the standard output.  The file operands are processed in command-line order.  If file is a single dash (`-') or absent, cat reads from the standard input.  If file is a UNIX domain socket, cat connects to it and then reads it until EOF.  This complements the UNIX domain binding capability available in inetd(8).

     The options are as follows:

     -b      Number the non-blank output lines, starting at 1.

     -e      Display non-printing characters (see the -v option), and display a dollar sign (`$') at the end of each line.

NAME
     cat -- concatenate and print files

SYNOPSIS
     cat [-benstuv] [file ...]

DESCRIPTION
     The cat utility reads files sequentially, writing them to the standard output.  The file operands are processed in command-line order.  If file is a single dash (`-') or absent, cat reads from the standard input.  If file is a UNIX domain socket, cat connects to it and then reads it until EOF.  This complements the UNIX domain binding capability available in inetd(8).

     The options are as follows:

     -b      Number the non-blank output lines, starting at 1.

     -e      Display non-printing characters (see the -v option), and display a dollar sign (`$') at the end of each line.

     -n      Number the output lines, starting at 1.

     -s      Squeeze multiple adjacent empty lines, causing the output to be single spaced.

     -t      Display non-printing characters (see the -v option), and display tab characters as `^I'.

     -u      Disable output buffering.

     -v      Display non-printing characters so they are visible.  Control characters print as `^X' for control-X; the delete character (octal 0177) prints as `^?'.  Non-ASCII characters (with the high bit set) are printed as `M-' (for meta) followed by the character for the low 7 bits.

EXIT STATUS
     The cat utility exits 0 on success, and >0 if an error occurs.

EXAMPLES
     The command:

           cat file1

     will print the contents of file1 to the standard output.

     The command:

           cat file1 file2 > file3

     will sequentially print the contents of file1 and file2 to the file file3, truncating file3 if it already exists.  See the manual page for your shell (i.e., sh(1)) for more information on redirection.

     The command:

           cat file1 - file2 - file3

     will print the contents of file1, print data it receives from the standard input until it receives an EOF (`^D') character, print the contents of file2, read and output contents of the standard input again, then finally output the contents of file3.  Note
     that if the standard input referred to a file, the second dash on the command-line would have no effect, since the entire contents of the file would have already been read and printed by cat when it encountered the first `-' operand.

mowatermelon commented 3 years ago

有用指令学习

$ banner -w 80 watermelon
                                                 ## 
                                                 ## 
                                             ###### 
                                           ######## 
                                      ############# 
                                  ################# 
                               #################### 
                           ####################  ## 
                      ####################
                    ####################
                    ############### 
                         ####### 
                           ####### 
                           ############ 
                      ################### 
                    ################### 
                    ############### 
                         ####### 
                           ####### 
                               ######## 
                                    ########     ## 
                                       ########  ## 
                                            ####### 
                                             ###### 
                                                 ## 
                                                 ## 

                          #####
                        ######### 
                     ###############        ###
                    ################      ###### 
                   ##################     ######## 
                   #####         #####    #########
                   ####           ####      ##  ### 
                   ###            ####           ## 
                   ###            ###            ## 
                   ###            ###           ### 
                    ####         ###           #### 
                      #############################
                    ############################## 
                   ############################## 
                   ############################ 
                   ########################### 
                   ### 
                   # 
                   #
                                                 ## 
                                                 ## 
                         ################################## 
                       #################################### 
                    ####################################### 
                   ######################################## 
                   ######################################## 
                   ######                        ## 
                   #####                         ## 
                   #####                         ## 
                    ### 
                      ## 
                        # 
                              ########## 
                           #################
                        ###################### 
                       ######################## 
                     ############################ 
                    #####         ##         ##### 
                    ####          ##          #### 
                   ###            ##            ###
                   ##             ##             ## 
                   ##             ##             ## 
                   ##             ##             ## 
                   ##             ##            ###
                   ###            ##           ####
                    ##            ##         ##### 
                     ###          ############### 
                      ###         ############## 
                        ###       ############ 
                                  ##########
                                  ###### 
                   ##                            ## 
                   ##                            ## 
                   ################################ 
                   ################################ 
                   ################################ 
                   ################################ 
                   ################################ 
                   ##                      ####
                                            #### 
                                             #### 
                                             ##### 
                                              #####
                                          ######### 
                                        ########### 
                                        ########### 
                                        ###########
                                        ########## 
                                          ##### 

                   ##                            ## 
                   ##                            ## 
                   ################################ 
                   ################################ 
                   ################################ 
                   ################################ 
                   ################################ 
                   ##                        ### 
                                               ###
                   ##                         #### 
                   ################################ 
                   ################################ 
                   ################################ 
                   ############################### 
                   #############################
                   ##                       ### 
                                              ### 
                   ##                         #### 
                   ##                        ######
                   ################################ 
                   ################################ 
                   ################################
                   ###############################
                   #############################
                   ## 
                              ########## 
                           #################
                        ###################### 
                       ######################## 
                     ############################ 
                    #####         ##         ##### 
                    ####          ##          #### 
                   ###            ##            ###
                   ##             ##             ## 
                   ##             ##             ## 
                   ##             ##             ## 
                   ##             ##            ###
                   ###            ##           ####
                    ##            ##         ##### 
                     ###          ############### 
                      ###         ############## 
                        ###       ############ 
                                  ##########
                                  ###### 
                   ##                                                  ###
                   ##                                                  ###
                   #######################################################
                   #######################################################
                   #######################################################
                   #######################################################
                   #######################################################
                   ## 
                              ########## 
                           #################
                        ###################### 
                       ######################## 
                     ############################ 
                    #####                    ##### 
                    ####                      #### 
                   ###                          ###
                   ##                            ## 
                   ##                            ## 
                   ##                            ## 
                   ###                          ### 
                   ###                          ###
                    ####                      #### 
                    ########              ########
                     ############################ 
                       ######################## 
                         ####################
                           #################

                   ##                            ## 
                   ##                            ## 
                   ################################ 
                   ################################ 
                   ################################ 
                   ################################ 
                   ################################ 
                   ##                        ### 
                                               ###
                                               ### 
                                               ####
                                               #### 
                                               #### 
                   ##                       ####### 
                   ################################
                   ################################
                   ###############################
                   ############################
                   ######################### 
                   ## 

-textutil -convert <type> <fileName>这句指令允许你将任何文件,在以下文件格式中互相转换 txt, html, rtf, rtfd, doc, docx, wordml, odt, webarchive。


参考文档

mowatermelon commented 3 years ago

split 指令学习

基础介绍

$  xargs [-0oprt] [-E eofstr] [-I replstr [-R replacements] [-S replsize]] [-J replstr] [-L number] [-n number [-x]] [-P maxprocs] [-s size] [utility [argument ...]]

$ ls | grep xxsplit |  xargs -n1 -I{} mv {} {}.mp4

最开始是希望一个指令就行,但是后面尝试了好些参数没有出来,最后加上了 mv 指令才成功

$ split -a 5 -b 1024m 拉钩大前端成长营.mp4  xxsplit && ls | grep xxsplit | xargs -n1 -I {} mv {} {}.mp4  &&  ls | grep xxsplit

xxsplitaaaaa.mp4
xxsplitaaaab.mp4
xxsplitaaaac.mp4
xxsplitaaaad.mp4
xxsplitaaaae.mp4

xargs -n1 –i{} 类似 for 循环,-n1 意思是一个一个对象的去处理,-i{} 把前面的对象使用{}取代,mv {} {}.mp4 相当于 mv xxsplitaaaaa xxsplitaaaaa.mp4


参数说明

通过 man xargs 进入说明,按 q 键直接退出


XARGS(1)                  BSD General Commands Manual                 XARGS(1)

NAME
     xargs -- construct argument list(s) and execute utility

SYNOPSIS
     xargs [-0oprt] [-E eofstr] [-I replstr [-R replacements] [-S replsize]] [-J replstr] [-L number] [-n number [-x]] [-P maxprocs] [-s size] [utility [argument ...]]

DESCRIPTION
     The xargs utility reads space, tab, newline and end-of-file delimited strings from the standard input and executes utility with the strings as arguments.

     Any arguments specified on the command line are given to utility upon each invocation, followed by some number of the arguments read from the standard input of xargs.  This is repeated until standard input is exhausted.

     Spaces, tabs and newlines may be embedded in arguments using single (`` ' '') or double (``"'') quotes or backslashes (``\'').  Single quotes escape all non-single quote characters, excluding newlines, up to the matching single quote.  Double quotes escape
     all non-double quote characters, excluding newlines, up to the matching double quote.  Any single character, including newlines, may be escaped by a backslash.

     The options are as follows:

     -0      Change xargs to expect NUL (``\0'') characters as separators, instead of spaces and newlines.  This is expected to be used in concert with the -print0 function in find(1).

     -E eofstr
             Use eofstr as a logical EOF marker.

     -I replstr
             Execute utility for each input line, replacing one or more occurrences of replstr in up to replacements (or 5 if no -R flag is specified) arguments to utility with the entire line of input.  The resulting arguments, after replacement is done, will
             not be allowed to grow beyond replsize (or 255 if no -S flag is specified) bytes; this is implemented by concatenating as much of the argument containing replstr as possible, to the constructed arguments to utility, up to replsize bytes.  The size
             limit does not apply to arguments to utility which do not contain replstr, and furthermore, no replacement will be done on utility itself.  Implies -x.

     -J replstr
             If this option is specified, xargs will use the data read from standard input to replace the first occurrence of replstr instead of appending that data after all other arguments.  This option will not affect how many arguments will be read from
             input (-n), or the size of the command(s) xargs will generate (-s).  The option just moves where those arguments will be placed in the command(s) that are executed.  The replstr must show up as a distinct argument to xargs.  It will not be recog-
             nized if, for instance, it is in the middle of a quoted string.  Furthermore, only the first occurrence of the replstr will be replaced.  For example, the following command will copy the list of files and directories which start with an uppercase
             letter in the current directory to destdir:

                   /bin/ls -1d [A-Z]* | xargs -J % cp -Rp % destdir

     -L number
             Call utility for every number non-empty lines read.  A line ending with a space continues to the next non-empty line.  If EOF is reached and fewer lines have been read than number then utility will be called with the available lines.  The -L and -n
             options are mutually-exclusive; the last one given will be used.

     -n number
             Set the maximum number of arguments taken from standard input for each invocation of utility.  An invocation of utility will use less than number standard input arguments if the number of bytes accumulated (see the -s option) exceeds the specified
             size or there are fewer than number arguments remaining for the last invocation of utility.  The current default value for number is 5000.

     -o      Reopen stdin as /dev/tty in the child process before executing the command.  This is useful if you want xargs to run an interactive application.

     -P maxprocs
             Parallel mode: run at most maxprocs invocations of utility at once.  If maxprocs is set to 0, xargs will run as many processes as possible.

     -p      Echo each command to be executed and ask the user whether it should be executed.  An affirmative response, `y' in the POSIX locale, causes the command to be executed, any other response causes it to be skipped.  No commands are executed if the
             process is not attached to a terminal.

     -r      Compatibility with GNU xargs.  The GNU version of xargs runs the utility argument at least once, even if xargs input is empty, and it supports a -r option to inhibit this behavior.  The FreeBSD version of xargs does not run the utility argument on
             empty input, but it supports the -r option for command-line compatibility with GNU xargs, but the -r option does nothing in the FreeBSD version of xargs.

     -R replacements
             Specify the maximum number of arguments that -I will do replacement in.  If replacements is negative, the number of arguments in which to replace is unbounded.

     -S replsize
             Specify the amount of space (in bytes) that -I can use for replacements.  The default for replsize is 255.

     -s size
             Set the maximum number of bytes for the command line length provided to utility.  The sum of the length of the utility name, the arguments passed to utility (including NULL terminators) and the current environment will be less than or equal to this
             number.  The current default value for size is ARG_MAX - 4096.

     -t      Echo the command to be executed to standard error immediately before it is executed.

     -x      Force xargs to terminate immediately if a command line containing number arguments will not fit in the specified (or default) command line length.

     If utility is omitted, echo(1) is used.

     Undefined behavior may occur if utility reads from the standard input.

     The xargs utility exits immediately (without processing any further input) if a command line cannot be assembled, utility cannot be invoked, an invocation of utility is terminated by a signal, or an invocation of utility exits with a value of 255, the
     xargs utility stops processing input and exits after all invocations of utility finish processing.

LEGACY DESCRIPTION
     In legacy mode, the -L option treats all newlines as end-of-line, regardless of whether the line is empty or ends with a space.  In addition, the -L and -n options are not mutually-exclusive.

     For more information about legacy mode, see compat(5).

EXIT STATUS
     The xargs utility exits with a value of 0 if no error occurs.  If utility cannot be found, xargs exits with a value of 127, otherwise if utility cannot be executed, xargs exits with a value of 126.  If any other error occurs, xargs exits with a value of 1.

SEE ALSO
     echo(1), find(1), execvp(3), compat(5)

STANDARDS
     The xargs utility is expected to be IEEE Std 1003.2 (``POSIX.2'') compliant.  The -J, -o, -P, -R and -S options are non-standard FreeBSD extensions which may not be available on other operating systems.

HISTORY
     The xargs utility appeared in PWB UNIX.

BUGS
     If utility attempts to invoke another command such that the number of arguments or the size of the environment is increased, it risks execvp(3) failing with E2BIG.

     The xargs utility does not take multibyte characters into account when performing string comparisons for the -I and -J options, which may lead to incorrect results in some locales.

参考文章

mowatermelon commented 3 years ago

默认设置 defaults

上面这些 defaults 开始的指令,实际修改的是系统默认的 Plist 表单,这些表单管理着系统中全部程序的默认设置,上面所做的修改无非是改了某些程序的默认设置罢了。

若你想查看还有哪些可以修改,可以在访达中按下键盘 ⌥Option,点击「前往 - 资源库」,找到 Perference 文件夹,你会发现所有的 Plist 文件均在这里,你也可以根据便好手动修改。

image

mowatermelon commented 3 years ago