Open mowatermelon opened 3 years ago
$ 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.
folderName
下的子文件defaults write com.apple.finder AppleShowAllFiles -bool true; killall Finder
显示隐藏文件夹defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'; killall Dock
你也许会发现,底部的程序栏越用越乱,有时候内容多的半天找不到所需程序。defaults delete com.apple.dock; killall Dock
当你想要重新整理底部程序栏时,有时候从默认状态开始整理也许是个好办法。pwd
查看当前文件夹路径banner -w 80 watermelon
当你想要打出机械感十足的文字时,只需要将代码结尾处的文字替换为你想打印的字即可。$ banner -w 80 watermelon
##
##
######
########
#############
#################
####################
#################### ##
####################
####################
###############
#######
#######
############
###################
###################
###############
#######
#######
########
######## ##
######## ##
#######
######
##
##
#####
#########
############### ###
################ ######
################## ########
##### ##### #########
#### #### ## ###
### #### ##
### ### ##
### ### ###
#### ### ####
#############################
##############################
##############################
############################
###########################
###
#
#
##
##
##################################
####################################
#######################################
########################################
########################################
###### ##
##### ##
##### ##
###
##
#
##########
#################
######################
########################
############################
##### ## #####
#### ## ####
### ## ###
## ## ##
## ## ##
## ## ##
## ## ###
### ## ####
## ## #####
### ###############
### ##############
### ############
##########
######
## ##
## ##
################################
################################
################################
################################
################################
## ####
####
####
#####
#####
#########
###########
###########
###########
##########
#####
## ##
## ##
################################
################################
################################
################################
################################
## ###
###
## ####
################################
################################
################################
###############################
#############################
## ###
###
## ####
## ######
################################
################################
################################
###############################
#############################
##
##########
#################
######################
########################
############################
##### ## #####
#### ## ####
### ## ###
## ## ##
## ## ##
## ## ##
## ## ###
### ## ####
## ## #####
### ###############
### ##############
### ############
##########
######
## ###
## ###
#######################################################
#######################################################
#######################################################
#######################################################
#######################################################
##
##########
#################
######################
########################
############################
##### #####
#### ####
### ###
## ##
## ##
## ##
### ###
### ###
#### ####
######## ########
############################
########################
####################
#################
## ##
## ##
################################
################################
################################
################################
################################
## ###
###
###
####
####
####
## #######
################################
################################
###############################
############################
#########################
##
-textutil -convert <type> <fileName>
这句指令允许你将任何文件,在以下文件格式中互相转换 txt, html, rtf, rtfd, doc, docx, wordml, odt, webarchive。
$ 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.
上面这些 defaults 开始的指令,实际修改的是系统默认的 Plist 表单,这些表单管理着系统中全部程序的默认设置,上面所做的修改无非是改了某些程序的默认设置罢了。
若你想查看还有哪些可以修改,可以在访达中按下键盘 ⌥Option,点击「前往 - 资源库」,找到 Perference 文件夹,你会发现所有的 Plist 文件均在这里,你也可以根据便好手动修改。
split 指令学习
基础介绍
按照固定行数或者估计大小分割单个文件,分割完成是没有后缀名的
参数说明
-l
参数,这个参数不起效果比较可惜的是 Linux 下,还支持
-d
让后缀默认按照数字格式进行增长,Mac 上没有