Documentation
¶
Index ¶
Constants ¶
const CPCMDVersion = "0.0.1"
CPCMDVersion cp version
const CSplitCMDVersion = "0.0.1"
CSplitCMDVersion csplit version
const ChGrpCMDVersion = "0.0.1"
ChGrpCMDVersion chgrp version
const ChModCMDVersion = "0.0.1"
ChModCMDVersion chmod version
const ChOwnCMDVersion = "0.0.1"
ChOwnCMDVersion chown version
const ChRootCMDVersion = "0.0.1"
ChRootCMDVersion chroor version
const CkSumCMDVersion = "0.0.1"
CkSumCMDVersion cksum version
const CutCMDVersion = "0.0.1"
CutCMDVersion cut version
const DDCMDVersion = "0.0.1"
DDCMDVersion dd version
const DateCMDVersion = "0.0.1"
DateCMDVersion date version
const DirNameCMDVersion = "0.0.1"
DirNameCMDVersion dirname version
const ExpandCMDVersion = "0.0.1"
ExpandCMDVersion expand version
const ExprCMDVersion = "0.0.1"
ExprCMDVersion expr version
const FactorCMDVersion = "0.0.1"
FactorCMDVersion factor version
const FalseCMDVersion = "0.0.1"
FalseCMDVersion false version
const HeadCMDVersion = "0.0.1"
HeadCMDVersion head version
const JoinCMDVersion = "0.0.1"
JoinCMDVersion join version
const NProcCMDVersion = "0.0.1"
NProcCMDVersion nproc version
const NiceCMDVersion = "0.0.1"
NiceCMDVersion nice version
const NumFmtCMDVersion = "0.0.1"
NumFmtCMDVersion numfmt version
const PasteCMDVersion = "0.0.1"
PasteCMDVersion paste version
const PathChkCMDVersion = "0.0.1"
PathChkCMDVersion pathchk version
const PtxCMDVersion = "0.0.1"
PtxCMDVersion ptx version
const RealPathCMDVersion = "0.0.1"
RealPathCMDVersion realpath version
const ShredCMDVersion = "0.0.1"
ShredCMDVersion shred version
const ShufCMDVersion = "0.0.1"
ShufCMDVersion shuf version
const SortCMDVersion = "0.0.1"
SortCMDVersion sort version
const SplitCMDVersion = "0.0.1"
SplitCMDVersion split version
const SyncCMDVersion = "0.0.1"
SyncCMDVersion sync version
const TSortCMDVersion = "0.0.1"
TSortCMDVersion tsort version
const TailCMDVersion = "0.0.1"
TailCMDVersion tail version
const TeeCMDVersion = "0.0.1"
TeeCMDVersion tee version
const TestCMDVersion = "0.0.1"
TestCMDVersion yes version
const TimeoutCMDVersion = "0.0.1"
TimeoutCMDVersion timeout version
const TrCMDVersion = "0.0.1"
TrCMDVersion tr version
const TrueCMDVersion = "0.0.1"
TrueCMDVersion true version
const TruncateCMDVersion = "0.0.1"
TruncateCMDVersion truncate version
const UNameCMDVersion = "0.0.1"
UNameCMDVersion version number
const UnExpandCMDVersion = "0.0.1"
UnExpandCMDVersion unexpand version
const UniqCMDVersion = "0.0.1"
UniqCMDVersion uniq version
const YesCMDVersion = "0.0.1"
YesCMDVersion yes version
Variables ¶
var ArchCMD = cli.Command{ Name: "arch", Aliases: []string{"ARCH"}, Usage: "打印机器硬件名称 (同 uname -m)", Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: archAction, }
ArchCMD define arch cli command
var ArchCMDVersion = "v0.0.1"
ArchCMDVersion arch version no
var Base32CMD = cli.Command{ Name: "base32", Aliases: []string{"BASE32"}, Usage: "base32编码/解码数据并打印到标准输出", Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "output this help information and exit", }, &cli.BoolFlag{ Name: "decode", Aliases: []string{"d"}, Usage: "decode data", }, &cli.BoolFlag{ Name: "ignore-garbag", Aliases: []string{"i"}, Usage: "ignore non-char while decoding", }, &cli.Int64Flag{ Name: "wrap", Aliases: []string{"w"}, Value: 76, Usage: "在指定的字符数后自动换行(默认为76),0 为禁用自动换行", }, }, Action: base32Action, }
Base32CMD define base32 cli command
var Base32CMDVersion = "v0.0.1"
Base32CMDVersion base32 version no
var Base64CMD = cli.Command{ Name: "base64", Aliases: []string{"BASE64"}, Usage: "base64编码/解码数据并打印到标准输出", Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "output this help information and exit", }, &cli.BoolFlag{ Name: "decode", Aliases: []string{"d"}, Usage: "decode data", }, &cli.BoolFlag{ Name: "ignore-garbag", Aliases: []string{"i"}, Usage: "ignore non-char while decoding", }, &cli.Int64Flag{ Name: "wrap", Aliases: []string{"w"}, Value: 76, Usage: "在指定的字符数后自动换行(默认为76),0 为禁用自动换行", }, }, Action: base64Action, }
Base64CMD define base64 cli command
var Base64CMDVersion = "v0.0.1"
Base64CMDVersion base64 version no
var BaseNameCMD = cli.Command{ Name: "basename", Aliases: []string{"BASENAME"}, Usage: "移除文件名的目录和后缀", Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "output this help information and exit", }, &cli.BoolFlag{ Name: "multiple", Aliases: []string{"a"}, Usage: "support multiple arguments and treat each as a NAME", }, &cli.StringFlag{ Name: "suffix", Aliases: []string{"s"}, Value: "/", Usage: "remove a trailing SUFFIX; implies -a", }, &cli.BoolFlag{ Name: "zero", Aliases: []string{"z"}, Usage: "end each output line with NUL, not newline", }, }, Action: baseNameAction, }
BaseNameCMD define basename cli command
var BaseNameCMDVersion = "v0.0.1"
BaseNameCMDVersion basename version no
var CPCMD = cli.Command{ Name: "cp", Aliases: []string{"CP"}, UsageText: "core cp [选项]... [-T] 源文件 目标文件]\ncore cp [选项]... 源文件... 目录\ncore cp [选项]... -t 目录 源文件...", Usage: "拷贝复制文件", Description: `默认情况下,源文件的稀疏性仅仅通过简单的方法判断,对应的目标文件目标文件也 被为稀疏。这是因为默认情况下使用了--sparse=auto 参数。如果明确使用 --sparse=always 参数则不论源文件是否包含足够长的0 序列也将目标文件创文 建为稀疏件。 使用--sparse=never 参数禁止创建稀疏文件。 当指定了--reflink[=always] 参数时执行轻量化的复制,即只在数据块被修改的 情况下才复制。如果复制失败或者同时指定了--reflink=auto,则返回标准复制模式。 The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX. The version control method may be selected via the --backup option or through the VERSION_CONTROL environment variable. Here are the values: none, off 不进行备份(即使使用了--backup 选项) numbered, t 备份文件加上数字进行排序 existing, nil 若有数字的备份文件已经存在则使用数字,否则使用普通方式备份 simple, never 永远使用普通方式备份 有一个特别情况:如果同时指定--force 和--backup 选项,而源文件和目标文件 是同一个已存在的一般文件的话,cp 会将源文件备份。`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, &cli.BoolFlag{ Name: "archive", Aliases: []string{""}, Usage: "等于-dR --preserve=all", }, &cli.BoolFlag{ Name: "attributes-only", Usage: "仅复制属性而不复制数据", }, &cli.BoolFlag{ Name: "backup", Usage: "为每个已存在的目标文件创建备份", }, &cli.BoolFlag{ Name: "b", Usage: "类似--backup 但不接受参数", }, &cli.BoolFlag{ Name: "copy-contents", Usage: "在递归处理是复制特殊文件内容", }, &cli.BoolFlag{ Name: "d", Usage: "等于--no-dereference --preserve=links", }, &cli.BoolFlag{ Name: "force", Aliases: []string{"f"}, Usage: "if an existing destination file cannot be opened, remove it and try again (this option is ignored when the -n option is also used)", }, &cli.BoolFlag{ Name: "interactive", Aliases: []string{"i"}, Usage: "prompt before overwrite (overrides a previous -n option)", }, &cli.BoolFlag{ Name: "H", Usage: "follow command-line symbolic links in SOURCE", }, &cli.BoolFlag{ Name: "link", Aliases: []string{"l"}, Usage: "hard link files instead of copying", }, &cli.BoolFlag{ Name: "dereference", Aliases: []string{"L"}, Usage: "always follow symbolic links in SOURCE", }, &cli.BoolFlag{ Name: "no-clobber", Aliases: []string{"n"}, Usage: "不要覆盖已存在的文件(使前面的 -i 选项失效)", }, &cli.BoolFlag{ Name: "no-dereferenc", Aliases: []string{"P"}, Usage: "不跟随源文件中的符号链接", }, &cli.BoolFlag{ Name: "p", Usage: "等于--preserve=模式,所有权,时间戳", }, &cli.StringSliceFlag{ Name: "preserve", Usage: "保持指定的`属性列表`(默认:模式,所有权,时间戳),如果可能保持附加属性:环境、链接、xattr 等", }, &cli.StringSliceFlag{ Name: "sno-preserve", Usage: "不保留指定的文件`属性列表`", }, &cli.BoolFlag{ Name: "parents", Usage: "复制前在目标目录创建来源文件路径中的所有目录", }, &cli.BoolFlag{ Name: "recursive", Aliases: []string{"r", "R"}, Usage: "递归复制目录及其子目录内的所有内容", }, &cli.StringFlag{ Name: "reflink", Usage: "控制克隆/CoW 副本。请查看下面的内容。", }, &cli.BoolFlag{ Name: "remove-destination", Usage: "尝试打开目标文件前先删除已存在的目的地文件 (相对于 --force 选项)", }, &cli.StringFlag{ Name: "sparse", Usage: "控制创建稀疏文件的方式", }, &cli.BoolFlag{ Name: "strip-trailing-slashes", Usage: "删除参数中所有源文件/目录末端的斜杠", }, &cli.BoolFlag{ Name: "symbolic-link", Aliases: []string{"s"}, Usage: "只创建符号链接而不复制文件", }, &cli.StringFlag{ Name: "suffix", Aliases: []string{"S"}, Usage: "自行指定备份文件的`后缀`", }, &cli.PathFlag{ Name: "target-directory", Aliases: []string{"t"}, Usage: "将所有参数指定的源文件/目录复制至目标`目录`", }, &cli.BoolFlag{ Name: "no-target-directory", Aliases: []string{"T"}, Usage: "将目标目录视作普通文件", }, &cli.BoolFlag{ Name: "update", Aliases: []string{"u"}, Usage: "只在源文件比目标文件新,或目标文件不存在时才进行复制", }, &cli.BoolFlag{ Name: "verbose", Usage: "显示详细的进行步骤", }, &cli.BoolFlag{ Name: "one-file-system", Aliases: []string{"x"}, Usage: "不跨越文件系统进行操作", }, &cli.BoolFlag{ Name: "Z", Usage: "et SELinux security context of destination file to default type", }, &cli.StringFlag{ Name: "context", Usage: "like -Z, or if CTX is specified then set the SELinux or SMACK security context to `CTX`", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(CPCMDVersion) return nil } return nil }, }
CPCMD define `cp` cmd
var CSplitCMD = cli.Command{ Name: "csplit", Aliases: []string{"CSPLIT"}, Usage: "将用PATTERN分隔的FILE输出到文件“ xx00”,“ xx01……", Description: `Output pieces of FILE separated by PATTERN(s) to files 'xx00', 'xx01', ..., and output byte counts of each piece to standard output. Read standard input if FILE is - Each PATTERN may be: INTEGER copy up to but not including specified line number /REGEXP/[OFFSET] copy up to but not including a matching line %REGEXP%[OFFSET] skip to, but not including a matching line {INTEGER} repeat the previous pattern specified number of times {*} repeat the previous pattern as many times as possible A line OFFSET is a required '+' or '-' followed by a positive integer.`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(CSplitCMDVersion) return nil } return nil }, }
CSplitCMD define `csplit` cmd
var CatCMD = cli.Command{ Name: "cat", Aliases: []string{"CAT"}, Usage: "连接所有指定文件并将结果写到标准输出", Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "显示版本信息并退出", }, &cli.BoolFlag{ Name: "show-all", Aliases: []string{"A"}, Usage: "等同于-vET", }, &cli.BoolFlag{ Name: "number-nonblank", Aliases: []string{"b"}, Usage: "number nonempty output lines, overrides -n", }, &cli.BoolFlag{ Name: "show-ends", Aliases: []string{"E"}, Usage: "display $ at end of each line", }, &cli.BoolFlag{ Name: "number", Aliases: []string{"n"}, Usage: "number all output lines", }, }, Action: catAction, }
CatCMD define cat cli command
var CatCMDVersion = "v0.0.1"
CatCMDVersion cat version no
var ChGrpCMD = cli.Command{ Name: "chgrp", Aliases: []string{"CHGRP"}, Usage: "更改组所有权", Description: `Change the group of each FILE to GROUP. With --reference, change the group of each FILE to that of RFILE. 示例: chgrp staff /u 将 /u 的属组更改为"staff"。 chgrp -hR staff /u 将 /u 及其子目录下所有文件的属组更改为"staff"。 `, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(ChGrpCMDVersion) return nil } return nil }, }
ChGrpCMD define `chgrp` cmd
var ChModCMD = cli.Command{ Name: "chmod", Aliases: []string{"CHMOD"}, Usage: "更改文件模式位", Description: `Change the mode of each FILE to MODE. With --reference, change the mode of each FILE to that of RFILE. Each MODE is of the form '[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+'.`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(ChModCMDVersion) return nil } return nil }, }
ChModCMD define `chmod` cmd
var ChOwnCMD = cli.Command{ Name: "chown", Aliases: []string{"CHOWN"}, Usage: "更改文件所有者和组", Description: `Change the owner and/or group of each FILE to OWNER and/or GROUP. With --reference, change the owner and group of each FILE to those of RFILE. Owner is unchanged if missing. Group is unchanged if missing, but changed to login group if implied by a ':' following a symbolic OWNER. OWNER and GROUP may be numeric as well as symbolic. 示例: chown root /u 将 /u 的属主更改为"root"。 chown root:staff /u 和上面类似,但同时也将其属组更改为"staff"。 chown -hR root /u 将 /u 及其子目录下所有文件的属主更改为"root"。`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(ChOwnCMDVersion) return nil } return nil }, }
ChOwnCMD define `chown` cmd
var ChRootCMD = cli.Command{ Name: "chroot", Aliases: []string{"CHROOT"}, Usage: "以指定的新根为运行指定命令时的的根目录。", Description: `If no command is given, run '"$SHELL" -i' (default: '/bin/sh -i').`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(ChRootCMDVersion) return nil } return nil }, }
ChRootCMD define `chroot` cmd
var CkSumCMD = cli.Command{ Name: "cksum", Aliases: []string{"CKSUM"}, UsageText: "core cksum [文件]...\ncore cksum [选项]", Usage: "输出每个文件的 CRC 校验值和字节统计。", Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(CkSumCMDVersion) return nil } return nil }, }
CkSumCMD define `cksum` cmd
var CommCMD = cli.Command{ Name: "comm", Aliases: []string{"COMM"}, Usage: "逐行比较已排序的文件文件1 和文件2", Description: `When FILE1 or FILE2 (not both) is -, read standard input. 如果不附带选项,程序会生成三列输出。第一列包含文件1 特有的行,第二列包含 文件2 特有的行, 而第三列包含两个文件共有的行。 Note, comparisons honor the rules specified by 'LC_COLLATE'. 示例: comm -12 文件1 文件2 只打印在文件1 和文件2 中都有的行 comm -3 文件1 文件2 打印在文件1 中有,而文件2 中没有的行。反之亦然。`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: commAction, }
CommCMD define comm cli command
var CommCMDVersion = "v0.0.1"
CommCMDVersion comm version no
var CutCMD = cli.Command{ Name: "cut", Aliases: []string{"CUT"}, Usage: "将每个文件中选定行的部分打印到标准输出", Description: `如果没有指定文件,或者文件为"-",则从标准输入读取`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(CutCMDVersion) return nil } return nil }, }
CutCMD define `cut` cmd
var DDCMD = cli.Command{ Name: "dd", Aliases: []string{"DD"}, Usage: "转换和拷贝文件", Description: `Copy a file, converting and formatting according to the operands. bs=BYTES read and write up to BYTES bytes at a time (default: 512); overrides ibs and obs cbs=BYTES convert BYTES bytes at a time conv=CONVS convert the file as per the comma separated symbol list count=N copy only N input blocks ibs=BYTES read up to BYTES bytes at a time (default: 512) if=FILE read from FILE instead of stdin iflag=FLAGS read as per the comma separated symbol list obs=BYTES write BYTES bytes at a time (default: 512) of=FILE write to FILE instead of stdout oflag=FLAGS write as per the comma separated symbol list seek=N skip N obs-sized blocks at start of output skip=N skip N ibs-sized blocks at start of input status=LEVEL The LEVEL of information to print to stderr; 'none' suppresses everything but error messages, 'noxfer' suppresses the final transfer statistics, 'progress' shows periodic transfer statistics N and BYTES may be followed by the following multiplicative suffixes: c =1, w =2, b =512, kB =1000, K =1024, MB =1000*1000, M =1024*1024, xM =M, GB =1000*1000*1000, G =1024*1024*1024, and so on for T, P, E, Z, Y. Each CONV symbol may be: ascii from EBCDIC to ASCII ebcdic from ASCII to EBCDIC ibm from ASCII to alternate EBCDIC block pad newline-terminated records with spaces to cbs-size unblock replace trailing spaces in cbs-size records with newline lcase change upper case to lower case ucase change lower case to upper case sparse try to seek rather than write the output for NUL input blocks swab swap every pair of input bytes sync pad every input block with NULs to ibs-size; when used with block or unblock, pad with spaces rather than NULs excl fail if the output file already exists nocreat do not create the output file notrunc 不截断输出文件 noerror 读取数据发生错误后仍然继续 fdatasync 结束前将输出文件数据写入磁盘 fsync 类似上面,但是元数据也一同写入 FLAG 符号可以是: append 追加模式(仅对输出有意义;隐含了conv=notrunc) direct 使用直接I/O 存取模式 directory 除非是目录,否则 directory 失败 dsync 使用同步I/O 存取模式 sync 与上者类似,但同时也对元数据生效 fullblock 为输入积累完整块(仅iflag) nonblock 使用无阻塞I/O 存取模式 noatime 不更新存取时间 nocache Request to drop cache. See also oflag=sync noctty 不根据文件指派控制终端 nofollow 不跟随链接文件 count_bytes treat 'count=N' as a byte count (iflag only) skip_bytes treat 'skip=N' as a byte count (iflag only) seek_bytes treat 'seek=N' as a byte count (oflag only) Sending a USR1 signal to a running 'dd' process makes it print I/O statistics to standard error and then resume copying.`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(DDCMDVersion) return nil } return nil }, }
DDCMD define `dd` cmd
var DateCMD = cli.Command{ Name: "date", Aliases: []string{"DATE"}, Usage: "打印或设置系统日期和时间", Description: `Display the current time in the given FORMAT, or set the system date. 给定的格式FORMAT 控制着输出,解释序列如下: %% 一个文字的 % %a 当前locale 的星期名缩写(例如: 日,代表星期日) %A 当前locale 的星期名全称 (如:星期日) %b 当前locale 的月名缩写 (如:一,代表一月) %B 当前locale 的月名全称 (如:一月) %c 当前locale 的日期和时间 (如:2005年3月3日 星期四 23:05:25) %C 世纪;比如 %Y,通常为省略当前年份的后两位数字(例如:20) %d 按月计的日期(例如:01) %D 按月计的日期;等于%m/%d/%y %e 按月计的日期,添加空格,等于%_d %F 完整日期格式,等价于 %Y-%m-%d %g ISO-8601 格式年份的最后两位 (参见%G) %G ISO-8601 格式年份 (参见%V),一般只和 %V 结合使用 %h 等于%b %H 小时(00-23) %I 小时(00-12) %j 按年计的日期(001-366) %k hour, space padded ( 0..23); same as %_H %l hour, space padded ( 1..12); same as %_I %m month (01..12) %M minute (00..59) %n a newline %N nanoseconds (000000000..999999999) %p locale's equivalent of either AM or PM; blank if not known %P like %p, but lower case %q quarter of year (1..4) %r locale's 12-hour clock time (e.g., 11:11:04 PM) %R 24-hour hour and minute; same as %H:%M %s seconds since 1970-01-01 00:00:00 UTC %S 秒(00-60) %t 输出制表符 Tab %T 时间,等于%H:%M:%S %u 星期,1 代表星期一 %U 一年中的第几周,以周日为每星期第一天(00-53) %V ISO-8601 格式规范下的一年中第几周,以周一为每星期第一天(01-53) %w 一星期中的第几日(0-6),0 代表周一 %W 一年中的第几周,以周一为每星期第一天(00-53) %x 当前locale 下的日期描述 (如:12/31/99) %X 当前locale 下的时间描述 (如:23:13:48) %y 年份最后两位数位 (00-99) %Y 年份 %z +hhmm 数字时区(例如,-0400) %:z +hh:mm 数字时区(例如,-04:00) %::z +hh:mm:ss 数字时区(例如,-04:00:00) %:::z 数字时区带有必要的精度 (例如,-04,+05:30) %Z 按字母表排序的时区缩写 (例如,EDT) 默认情况下,日期的数字区域以0 填充。 The following optional flags may follow '%': - (hyphen) do not pad the field _ (underscore) pad with spaces 0 (zero) pad with zeros ^ use upper case if possible # use opposite case if possible 在任何标记之后还允许一个可选的域宽度指定,它是一个十进制数字。 作为一个可选的修饰声明,它可以是E,在可能的情况下使用本地环境关联的 表示方式;或者是O,在可能的情况下使用本地环境关联的数字符号。 Examples: Convert seconds since the epoch (1970-01-01 UTC) to a date $ date --date='@2147483647' Show the time on the west coast of the US (use tzselect(1) to find TZ) $ TZ='America/Los_Angeles' date Show the local time for 9AM next Friday on the west coast of the US $ date --date='TZ="America/Los_Angeles" 09:00 next Fri'`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, &cli.StringFlag{ Name: "date", Aliases: []string{"d"}, Usage: "display time described by `STRING`, not 'now'", }, &cli.BoolFlag{ Name: "debug", Usage: "annotate the parsed date, and warn about questionable usage to stderr", }, &cli.PathFlag{ Name: "file", Aliases: []string{"f"}, Usage: "like --date; once for each line of `DATEFILE`", }, &cli.BoolFlag{ Name: "rfc-email", Aliases: []string{"R"}, Usage: "output date and time in RFC 5322 format. Example: Mon, 14 Aug 2006 02:34:56 -0600", }, &cli.StringFlag{ Name: "rfc-3339", Usage: "output date/time in RFC 3339 format. FMT='date', 'seconds', or 'ns' for date and time to the indicated precision. Example: 2006-08-14 02:34:56-06:00", }, &cli.StringFlag{ Name: "reference", Aliases: []string{"r"}, Usage: "display the last modification time of `FILE`", }, &cli.StringFlag{ Name: "set", Aliases: []string{"s"}, Usage: "set time described by `STRING`", }, &cli.BoolFlag{ Name: "utc", Aliases: []string{"u"}, Usage: "print or set Coordinated Universal Time (UTC)", }, &cli.BoolFlag{ Name: "universal", Usage: "the same as --utc", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(DateCMDVersion) return nil } t := time.Now() local := t.Format(layout) w := t.Weekday().String() fmt.Println(strings.ReplaceAll(local, w, weekMap[w])) return nil }, }
DateCMD define `date` cmd
var DfCMD = cli.Command{ Name: "df", Aliases: []string{"DF"}, UsageText: "core df [选项]... [文件]...", Usage: `显示文件系统信息`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, &cli.BoolFlag{ Name: "all", Aliases: []string{"a"}, Usage: "include pseudo, duplicate, inaccessible file systems", }, &cli.StringFlag{ Name: "block-size", Aliases: []string{"B"}, Usage: `scale sizes by SIZE before printing them; e.g., '-BM' prints sizes in units of 1,048,576 bytes; see SIZE format below`, }, &cli.BoolFlag{ Name: "human-readable", Aliases: []string{"hu"}, Usage: "print sizes in powers of 1024 (e.g., 1023M)", }, &cli.BoolFlag{ Name: "si", Aliases: []string{"H"}, Usage: "print sizes in powers of 1000 (e.g., 1.1G)", }, &cli.BoolFlag{ Name: "inodes", Aliases: []string{"i"}, Usage: "显示inode 信息而非块使用量", }, &cli.BoolFlag{ Name: "local", Aliases: []string{"l"}, Usage: "只显示本机的文件系统", }, &cli.BoolFlag{ Name: "no-sync", Value: true, Usage: "取得使用量数据前不进行同步动作", }, &cli.BoolFlag{ Name: "portability", Aliases: []string{"P"}, Usage: "use the POSIX output format", }, &cli.BoolFlag{ Name: "sync", Usage: "invoke sync before getting usage info", }, &cli.BoolFlag{ Name: "total", Usage: ` elide all entries insignificant to available space, and produce a grand total`, }, &cli.StringFlag{ Name: "type", Aliases: []string{"t"}, Usage: "imit listing to file systems of type TYPE", }, &cli.BoolFlag{ Name: "print-type", Aliases: []string{"T"}, Usage: " print file system type", }, &cli.StringFlag{ Name: "exclude-type", Aliases: []string{"x"}, Usage: "limit listing to file systems not of type TYPE", }, }, Action: dfAction, }
DfCMD define df cli command
var DfCMDVersion = "v0.0.1"
DfCMDVersion df version no
var DirNameCMD = cli.Command{ Name: "dirname", Aliases: []string{"DIRNAME"}, UsageText: "core dirname [选项] 名称...", Usage: "输出每个NAME的最后一个非斜杠组成部分,并删除尾随的斜杠", Description: `Output each NAME with its last non-slash component and trailing slashes removed; if NAME contains no /'s, output '.' (meaning the current directory). Examples: dirname /usr/bin/ -> "/usr" dirname dir1/str dir2/str -> "dir1" followed by "dir2" dirname stdio.h -> "."`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, &cli.BoolFlag{ Name: "zero", Aliases: []string{"z"}, Usage: "end each output line with NUL, not newline", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(DirNameCMDVersion) return nil } if c.Args().Len() == 0 { return errors.New("缺少操作对象") } end := "\n" if c.Bool("zero") { end = "" } for _, p := range c.Args().Slice() { fmt.Printf("%s%s", filepath.Dir(p), end) } return nil }, }
DirNameCMD define dirname cmd
var DuCMD = cli.Command{ Name: "du", Aliases: []string{"DU"}, Usage: `递归地汇总目录或文件的磁盘使用情况`, Description: `所显示的数值是来自 --block-size、DU_BLOCK_SIZE、BLOCK_SIZE 及 BLOCKSIZE 环境变量中第一个可用的 SIZE 单位。 否则,默认单位是 1024 字节(或是 512,若设定 POSIXLY_CORRECT 的话)。 The SIZE argument is an integer and optional unit (example: 10K is 10*1024). Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000)`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, &cli.BoolFlag{ Name: "null", Aliases: []string{"0"}, Usage: "end each output line with NUL, not newline", }, &cli.BoolFlag{ Name: "all", Aliases: []string{"a"}, Usage: "write counts for all files, not just directories", }, &cli.Int64Flag{ Name: "apparent-size", Usage: `print apparent sizes, rather than disk usage; although the apparent size is usually smaller, it may be larger due to holes in ('sparse') files, internal fragmentation, indirect blocks, and the like`, }, &cli.StringFlag{ Name: "block-size", Aliases: []string{"B"}, Usage: `scale sizes by SIZE before printing them; e.g., '-BM' prints sizes in units of 1,048,576 bytes; see SIZE format below`, }, &cli.BoolFlag{ Name: "bytes", Aliases: []string{"b"}, Usage: `equivalent to '--apparent-size --block-size=1'`, }, &cli.BoolFlag{ Name: "total", Aliases: []string{"c"}, Usage: ` produce a grand total`, }, &cli.StringSliceFlag{ Name: "dereference-args", Aliases: []string{"D"}, Usage: `dereference only symlinks that are listed on the command line`, }, &cli.Int64Flag{ Name: "max-depth", Aliases: []string{"d"}, Usage: `print the total for a directory (or file, with --all) only if it is N or fewer levels below the command line argument; --max-depth=0 is the same as --summarize`, }, &cli.StringFlag{ Name: "files0-from", Usage: `summarize disk usage of the NUL-terminated file names specified in file F; if F is -, then read names from standard input`, }, &cli.BoolFlag{ Name: "human-readable", Aliases: []string{"hu"}, Usage: `print sizes in human readable format (e.g., 1K 234M 2G)`, }, &cli.BoolFlag{ Name: "inodes", Usage: `list inode usage information instead of block usage`, }, &cli.BoolFlag{ Name: "dereference", Aliases: []string{"L"}, Usage: `dereference all symbolic links`, }, &cli.BoolFlag{ Name: "count-links", Aliases: []string{"l"}, Usage: `count sizes many times if hard linked`, }, &cli.BoolFlag{ Name: "block-size-m", Aliases: []string{"m"}, Usage: `like --block-size=1M`, }, &cli.BoolFlag{ Name: "block-size-k", Aliases: []string{"k"}, Usage: `like --block-size=1K`, }, &cli.BoolFlag{ Name: "no-dereference", Aliases: []string{"P"}, Usage: `don't follow any symbolic links (this is the default)`, }, &cli.BoolFlag{ Name: "separate-dirs", Aliases: []string{"S"}, Usage: `for directories do not include size of subdirectories`, }, &cli.BoolFlag{ Name: "si", Usage: `like -hu, but use powers of 1000 not 1024`, }, &cli.BoolFlag{ Name: "summarize", Aliases: []string{"s"}, Usage: `display only a total for each argument`, }, &cli.Int64Flag{ Name: "threshold", Aliases: []string{"t"}, Usage: `exclude entries smaller than SIZE if positive, or entries greater than SIZE if negative`, }, &cli.BoolFlag{ Name: "time", Usage: `show time of the last modification of any file in the directory, or any of its subdirectorie`, }, &cli.BoolFlag{ Name: "time-word", Usage: `show time as WORD instead of modification time: atime, access, use, ctime or status`, }, &cli.StringFlag{ Name: "time-style", Usage: `show times using STYLE, which can be: full-iso, long-iso, iso, or +FORMAT; FORMAT is interpreted like in 'date'`, }, &cli.StringFlag{ Name: "exclude-from", Aliases: []string{"X"}, Usage: `exclude files that match any pattern in FILE`, }, &cli.StringFlag{ Name: "exclude", Usage: `exclude files that match PATTERN`, }, &cli.BoolFlag{ Name: "one-file-system", Aliases: []string{"x"}, Usage: `kip directories on different file systems`, }, }, Action: duAction, }
DuCMD define du cli command
var DuCMDVersion = "v0.0.1"
DuCMDVersion du version no
var EnvCMD = cli.Command{ Name: "env", Aliases: []string{"ENV"}, UsageText: "core env [选项]... [-] [名称=值]... [命令 [参数]...]", Usage: "在修改后的环境中运行程序", Description: `Set each NAME to VALUE in the environment and run COMMAND 单纯的 - 意味着 -i。如果没有命令,则打印结果环境。`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, &cli.BoolFlag{ Name: "ignore-environment", Aliases: []string{"i"}, Usage: `start with an empty environment`, }, &cli.BoolFlag{ Name: "null", Aliases: []string{"0"}, Usage: `end each output line with NUL, not newline`, }, &cli.StringFlag{ Name: "unset", Aliases: []string{"u"}, Usage: `remove variable from the environment`, }, &cli.PathFlag{ Name: `chdir`, Aliases: []string{"C"}, Usage: `change working directory to DIR`, }, }, Action: envAction, }
EnvCMD define env cli command
var EnvCMDVersion = "v0.0.1"
EnvCMDVersion env version no
var ExpandCMD = cli.Command{ Name: "expand", Aliases: []string{"EXPAND"}, UsageText: "core expand [选项]... [文件]...", Usage: "制表符转换为空格", Description: `Convert tabs in each FILE to spaces, writing to standard output. 如果没有指定文件,或者文件为"-",则从标准输入读取。`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, &cli.BoolFlag{ Name: "initial", Aliases: []string{"i"}, Usage: "do not convert tabs after non blanks", }, &cli.IntFlag{ Name: "tabs", Aliases: []string{"t"}, Usage: "have tabs `N` characters apart, not 8", Value: 8, }, }, Action: expandAction, }
ExpandCMD define `expand` cmd
var ExprCMD = cli.Command{ Name: "expr", Aliases: []string{"EXPR"}, Usage: "将表达式的值列印到标准输出,分隔符下面的空行可提升算式优先级。", Description: `可用的表达式有: ARG1 | ARG2 若ARG1 的值不为0 或者为空,则返回ARG1,否则返回ARG2 ARG1 & ARG2 若两边的值都不为0 或为空,则返回ARG1,否则返回 0 ARG1 < ARG2 ARG1 小于ARG2 ARG1 <= ARG2 ARG1 小于或等于ARG2 ARG1 = ARG2 ARG1 等于ARG2 ARG1 != ARG2 ARG1 不等于ARG2 ARG1 >= ARG2 ARG1 大于或等于ARG2 ARG1 > ARG2 ARG1 大于ARG2 ARG1 + ARG2 计算 ARG1 与ARG2 相加之和 ARG1 - ARG2 计算 ARG1 与ARG2 相减之差 ARG1 * ARG2 计算 ARG1 与ARG2 相乘之积 ARG1 / ARG2 计算 ARG1 与ARG2 相除之商 ARG1 % ARG2 计算 ARG1 与ARG2 相除之余数 字符串 : 表达式 定位字符串中匹配表达式的模式 match 字符串 表达式 等于"字符串 :表达式" substr 字符串 偏移量 长度 替换字符串的子串,偏移的数值从 1 起计 index 字符串 字符 在字符串中发现字符的地方建立下标,或者标0 length 字符串 字符串的长度 + TOKEN interpret TOKEN as a string, even if it is a keyword like 'match' or an operator like '/' ( EXPRESSION ) value of EXPRESSION 请注意有许多运算操作符都可能需要由 shell 先实施转义。 如果参与运算的 ARG 自变量都是数字,比较符就会被视作数学符号,否则就是多义的。 模式匹配会返回"\"和"\"之间被匹配的子字符串或空(null);如果未使用"\"和"\", 则会返回匹配字符数量或是 0。 若表达式的值既不是空也不是 0,退出状态值为 0;若表达式的值为空或为 0, 退出状态值为 1。如果表达式的句法无效,则会在出错时返回退出状态值 3。 `, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(ExprCMDVersion) return nil } return nil }, }
ExprCMD define `expr` cmd
var FactorCMD = cli.Command{ Name: "factor", Aliases: []string{"FACTOR"}, Usage: "输出每个指定的数字的素因子,如果没有在命令行中指定则从标准输入读取。", Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(FactorCMDVersion) return nil } return nil }, }
FactorCMD define `factor` cmd
var FalseCMD = cli.Command{ Name: "false", Aliases: []string{"FALSE"}, Usage: "返回布尔False", Description: "遵照IEEE Std 1003.2-1992 (``POSIX.2'') 总以非零退出码退出,", Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(TrueCMDVersion) return nil } os.Exit(1) return nil }, }
FalseCMD define `false` command
var GroupsCMD = cli.Command{ Name: "groups", Aliases: []string{"GROUPS"}, Usage: `显示每个输入的用户名所在的全部组, 如果没有指定用户名则默认为当前进程用户(当用户组数据库发生变更时可能导致差异)。`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: groupsAction, }
GroupsCMD define groups cli command
var GroupsCMDVersion = "v0.0.1"
GroupsCMDVersion groups version no
var HeadCMD = cli.Command{ Name: "head", UsageText: "core head [选项]... [文件]...", Aliases: []string{"HEAD"}, Usage: "打印文本文件的最前10行到标准输出", Description: `Print the first 10 lines of each FILE to standard output. With more than one FILE, precede each with a header giving the file name. 如果没有指定文件,或者文件为"-",则从标准输入读取。 NUM may have a multiplier suffix: b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024, GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y.`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, &cli.IntFlag{ Name: "bytes", Aliases: []string{"c"}, Usage: "print the first `NUM` bytes of each file;with the leading '-', print all but the last NUM bytes of each file", }, &cli.IntFlag{ Name: "lines", Aliases: []string{"n"}, Value: 10, Usage: "print the first `NUM` lines instead of the first 10;with the leading '-', print all but the last NUM lines of each file", }, &cli.BoolFlag{ Name: "silent", Aliases: []string{"s"}, Usage: "不显示包含给定文件名的文件头", }, &cli.BoolFlag{ Name: "quiet", Aliases: []string{"q"}, Usage: "和--silen相同", }, &cli.BoolFlag{ Name: "verbose", Aliases: []string{"V"}, Usage: "总是显示包含给定文件名的文件头", }, &cli.BoolFlag{ Name: "zero-terminated", Aliases: []string{"z"}, Usage: "以 NUL 字符而非换行符作为行尾分隔符", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(HeadCMDVersion) return nil } if c.Args().Len() == 0 { return errors.New("尚未实现标准输入读取") } linesNum := c.Int("lines") v := c.Bool("V") end := "\n" if c.Bool("z") { end = "" } for _, p := range c.Args().Slice() { file, err := os.Open(p) if err != nil { return err } scanner := bufio.NewScanner(file) index := 1 if v { fmt.Printf("==> %s <==\n", p) } for scanner.Scan() { fmt.Printf("%s%s", scanner.Text(), end) index++ if index > linesNum { break } } file.Close() } return nil }, }
HeadCMD define `head` cmd
var HostidCMD = cli.Command{ Name: "hostid", Aliases: []string{"HOSTID"}, Usage: "打印当前主机的数字标识符", Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: hostid, }
HostidCMD define hostid cli command
var HostidCMDVersion = "v0.0.1"
HostidCMDVersion hostid version no
var HostnameCMD = cli.Command{ Name: "hostname", Aliases: []string{"HOSTNAME"}, Usage: "显示或设置系统主机名", Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: hostname, }
HostnameCMD define hostname cli command
var HostnameCMDVersion = "v0.0.1"
HostnameCMDVersion hostname version no
var IDCMD = cli.Command{ Name: "id", Aliases: []string{"ID"}, Usage: `打印指定USER或当前用户(USER省略时)的用户和组信息`, Description: `如果不附带任何选项,程序会显示一些可供识别用户身份的有用信息。`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, &cli.BoolFlag{ Name: "context", Aliases: []string{"Z"}, Usage: `print only the security context of the process`, }, &cli.BoolFlag{ Name: "group", Aliases: []string{"g"}, Usage: `print only the effective group ID`, }, &cli.BoolFlag{ Name: "groups", Aliases: []string{"G"}, Usage: `print all group IDs`, }, &cli.BoolFlag{ Name: "name", Aliases: []string{"n"}, Usage: `print a name instead of a number, for -ugG`, }, &cli.BoolFlag{ Name: "real", Aliases: []string{"r"}, Usage: ` print the real ID instead of the effective ID, with -ugG`, }, &cli.BoolFlag{ Name: "user", Aliases: []string{"u"}, Usage: `print only the effective user ID`, }, &cli.BoolFlag{ Name: "zero", Aliases: []string{"z"}, Usage: `delimit entries with NUL characters, not whitespace; not permitted in default format`, }, }, Action: idAction, }
IDCMD define id cli command
var IDCMDVersion = "v0.0.1"
IDCMDVersion id version no
var JoinCMD = cli.Command{ Name: "join", Aliases: []string{"JOIN"}, Usage: "在一个公共字段上连接两个文件的行", Description: `For each pair of input lines with identical join fields, write a line to standard output. The default join field is the first, delimited by blanks. When FILE1 or FILE2 (not both) is -, read standard input. Unless -t CHAR is given, leading blanks separate fields and are ignored, else fields are separated by CHAR. Any FIELD is a field number counted from 1. FORMAT is one or more comma or blank separated specifications, each being 'FILENUM.FIELD' or '0'. Default FORMAT outputs the join field, the remaining fields from FILE1, the remaining fields from FILE2, all separated by CHAR. If FORMAT is the keyword 'auto', then the first line of each file determines the number of fields output for each line. Important: FILE1 and FILE2 must be sorted on the join fields. E.g., use "sort -k 1b,1" if 'join' has no options, or use "join -t ''" if 'sort' has no options. Note, comparisons honor the rules specified by 'LC_COLLATE'. If the input is not sorted and some lines cannot be joined, a warning message will be given.`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(JoinCMDVersion) return nil } return nil }, }
JoinCMD define `join` cmd
var LogNameCMD = cli.Command{ Name: "logname", Aliases: []string{"LOGNAME"}, Usage: `显示当前用户的名称`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: lognameAction, }
LogNameCMD define logname cli command
var LogNameCMDVersion = "v0.0.1"
LogNameCMDVersion logname version no
var LsCPUCMD = cli.Command{ Name: "lscpu", Aliases: []string{"LSCPU"}, Usage: "显示 CPU 架构信息", Description: `lscpu gathers CPU architecture information from sysfs, /proc/cpuinfo and any applicable architecture-specific libraries (e.g. librtas on Powerpc). The command output can be optimized for parsing or for easy readability by humans. The information includes, for example, the number of CPUs, threads, cores, sockets, and Non-Uniform Memory Access (NUMA) nodes. There is also information about the CPU caches and cache sharing, family, model, bogoMIPS, byte order, and stepping. In virtualized environments, the CPU architecture information displayed reflects the configuration of the guest oper‐ ating system which is typically different from the physical (host) system. On architectures that support retrieving physical topology information, lscpu also displays the number of physical sockets, chips, cores in the host system. Options that result in an output table have a list argument. Use this argument to customize the command output. Specify a comma-separated list of column labels to limit the output table to only the specified columns, arranged in the specified order. See COLUMNS for a list of valid column labels. The column labels are not case sensitive. Not all columns are supported on all architectures. If an unsupported column is specified, lscpu prints the column but does not provide any data for it. Available output columns: CPU 逻辑 CPU 数量 CORE 逻辑核心数量 SOCKET 逻辑(CPU)座数量 NODE 逻辑 NUMA 节点数量 BOOK 逻辑 book 数 DRAWER 逻辑抽屉号 CACHE 显示 CPU 间是如何共享缓存的 POLARIZATION 虚拟硬件上的 CPU 调度模式 ADDRESS CPU 的物理地址 CONFIGURED 显示超级监督(hypervisor)是否分配了 CPU ONLINE 显示 Linux 当前是否在使用该 CPU MAXMHZ 显示 CPU 的最大 MHz MINMHZ 显示 CPU 的最小 MHz`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, &cli.BoolFlag{ Name: "all", Aliases: []string{"a"}, Usage: `同时打印在线和离线 CPU (-e 选项默认值)`, }, &cli.BoolFlag{ Name: "online", Aliases: []string{"b"}, Usage: `只打印在线 CPU (-p 选项默认值)`, }, &cli.BoolFlag{ Name: "offline", Aliases: []string{"c"}, Usage: `只打印离线 CPU`, }, &cli.BoolFlag{ Name: `json`, Aliases: []string{"J"}, Usage: `use JSON for default or extended format`, }, &cli.StringSliceFlag{ Name: `extended`, Aliases: []string{"e"}, Usage: `打印扩展的可读格式`, }, &cli.StringSliceFlag{ Name: `parse`, Aliases: []string{"p"}, Usage: `打印可解析格式`, }, &cli.PathFlag{ Name: `sysroot`, Aliases: []string{"s"}, Usage: `以指定目录作为系统根目录`, }, &cli.BoolFlag{ Name: `hex`, Aliases: []string{"x"}, Usage: `打印十六进制掩码而非 CPU 列表`, }, &cli.BoolFlag{ Name: `physical`, Aliases: []string{"y"}, Usage: `打印物理 ID 而非逻辑 ID`, }, }, Action: lsCPUAction, }
LsCPUCMD define lscpu cli command
var LsCPUCMDVersion = "v0.0.1"
LsCPUCMDVersion lscpu version no
var MVCMD = cli.Command{ Name: "mv", Aliases: []string{"MV"}, Usage: "文件重命名或文件剪切", Description: `The backup suffix is '~', unless set with --suffix or SIMPLE_BACKUP_SUFFIX. The version control method may be selected via the --backup option or through the VERSION_CONTROL environment variable. Here are the values: none, off 不进行备份(即使使用了--backup 选项) numbered, t 备份文件加上数字进行排序 existing, nil 若有数字的备份文件已经存在则使用数字,否则使用普通方式备份 simple, never 永远使用普通方式备份`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: mvAction, }
MVCMD define mv cli command
var MVCMDVersion = "v0.0.1"
MVCMDVersion mv version no
var MkTempCMD = cli.Command{ Name: "mktemp", Aliases: []string{"MKTEMP"}, Usage: "创建临时文件、临时目录", Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, &cli.BoolFlag{ Name: "directory", Aliases: []string{"d"}, Usage: "create a directory, not a file", }, &cli.BoolFlag{ Name: "dry-run", Aliases: []string{"u"}, Usage: "do not create anything; merely print a name (unsafe)", }, &cli.StringFlag{ Name: "suffix", Aliases: []string{"s"}, Usage: "append SUFF to TEMPLATE; SUFF must not contain a slash. This option is implied if TEMPLATE does not end in X", }, &cli.StringFlag{ Name: "tmpdir", Aliases: []string{"p"}, Usage: `interpret TEMPLATE relative to DIR; if DIR is not specified, use $TMPDIR if set, else /tmp. With this option, TEMPLATE must not be an absolute name; unlike with -t, TEM‐ PLATE may contain slashes, but mktemp creates only the final component`, }, &cli.BoolFlag{ Name: "t", Usage: "interpret TEMPLATE as a single file name component, relative to a directory: $TMPDIR, if set; else the directory specified via -p; else /tmp [deprecated]", }, }, Action: mktemp, }
MkTempCMD define mktemp cli command
var MkTempCMDVersion = "v0.0.1"
MkTempCMDVersion mktemp version no
var NProcCMD = cli.Command{ Name: "nproc", Aliases: []string{"NPROC"}, Usage: "打印可用的处理器单元数", Description: `此数目可能小于实际工作数`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, &cli.BoolFlag{ Name: "all", Usage: "print the number of installed processors", }, &cli.IntFlag{ Name: "ignore", Usage: "if possible, exclude `N` processing units", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(NProcCMDVersion) return nil } return nil }, }
NProcCMD define `nproc` cmd
var NiceCMD = cli.Command{ Name: "nice", Aliases: []string{"NICE"}, Usage: "修改调度优先级运行程序", Description: `Run COMMAND with an adjusted niceness, which affects process scheduling. With no COMMAND, print the current niceness. Niceness values range from -20 (most favorable to the process) to 19 (least favorable to the process). `, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, &cli.IntFlag{ Name: "adjustment", Aliases: []string{"n"}, Usage: "add integer `N` to the niceness", Value: 10, }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(NiceCMDVersion) return nil } return nil }, }
NiceCMD define `nice` cmd
var NlCMD = cli.Command{ Name: "nl", Aliases: []string{"NL"}, Usage: "文本文件诸行添加数字编号打印到标准输出", Description: ` By default, selects -v1 -i1 -l1 -sTAB -w6 -nrn -hn -bt -fn. CC are two delimiter characters used to construct logical page delimiters, a missing second character implies :. Type \\ for \. STYLE is one of: a 对所有行编号 t 对非空行编号 n 不编行号 pBRE 只对符合正则表达式BRE 的行编号 FORMAT 是下列之一: ln 左对齐,空格不用0 填充 rn 右对齐,空格不用0 填充 rz 右对齐,空格用0 填充`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, &cli.StringFlag{ Name: "body-numbering", Aliases: []string{"b"}, Usage: "use STYLE for numbering body lines", }, &cli.StringFlag{ Name: "section-delimiter", Aliases: []string{"d"}, Usage: "use CC for logical page delimiters", }, &cli.StringFlag{ Name: "footer-numbering", Aliases: []string{"f"}, Usage: "use STYLE for numbering footer lines", }, &cli.StringFlag{ Name: "header-numbering", Aliases: []string{"he"}, Usage: "use STYLE for numbering header lines", }, &cli.Int64Flag{ Name: "line-increment", Aliases: []string{"i"}, Usage: "line number increment at each line", }, &cli.Int64Flag{ Name: "join-blank-lines", Aliases: []string{"l"}, Usage: "group of NUMBER empty lines counted as one", }, &cli.StringFlag{ Name: "number-format", Aliases: []string{"n"}, Usage: "insert line numbers according to FORMAT", }, &cli.BoolFlag{ Name: "no-renumber", Aliases: []string{"p"}, Usage: "do not reset line numbers for each section", }, &cli.StringFlag{ Name: "number-separator", Aliases: []string{"s"}, Usage: "add STRING after (possible) line number", }, &cli.Int64Flag{ Name: "starting-line-number", Aliases: []string{"sl"}, Usage: "first line number for each section", }, &cli.Int64Flag{ Name: "number-width", Aliases: []string{"w"}, Usage: "use NUMBER columns for line numbers", }, }, Action: nlAction, }
NlCMD define nl cli command
var NlCMDVersion = "v0.0.1"
NlCMDVersion nl version no
var NumFmtCMD = cli.Command{ Name: "numfmt", Aliases: []string{"NUMFMT"}, Usage: "将数字转换为人类可读的字符串", Description: `Reformat NUMBER(s), or the numbers from standard input if none are specified. UNIT options: none no auto-scaling is done; suffixes will trigger an error auto accept optional single/two letter suffix: 1K = 1000, 1Ki = 1024, 1M = 1000000, 1Mi = 1048576, si accept optional single letter suffix: 1K = 1000, 1M = 1000000, ... iec accept optional single letter suffix: 1K = 1024, 1M = 1048576, ... iec-i accept optional two-letter suffix: 1Ki = 1024, 1Mi = 1048576, ... FIELDS supports cut(1) style field ranges: N N'th field, counted from 1 N- from N'th field, to end of line N-M from N'th to M'th field (inclusive) -M from first to M'th field (inclusive) - all fields Multiple fields/ranges can be separated with commas FORMAT must be suitable for printing one floating-point argument '%f'. Optional quote (%'f) will enable --grouping (if supported by current locale). Optional width value (%10f) will pad output. Optional zero (%010f) width will zero pad the number. Optional negative values (%-10f) will left align. Optional precision (%.1f) will override the input determined precision. Exit status is 0 if all input numbers were successfully converted. By default, numfmt will stop at the first conversion error with exit status 2. With --invalid='fail' a warning is printed for each conversion error and the exit status is 2. With --invalid='warn' each conversion error is diagnosed, but the exit status is 0. With --invalid='ignore' conversion errors are not diagnosed and the exit status is 0. Examples: $ numfmt --to=si 1000 -> "1.0K" $ numfmt --to=iec 2048 -> "2.0K" $ numfmt --to=iec-i 4096 -> "4.0Ki" $ echo 1K | numfmt --from=si -> "1000" $ echo 1K | numfmt --from=iec -> "1024" $ df -B1 | numfmt --header --field 2-4 --to=si $ ls -l | numfmt --header --field 5 --to=iec $ ls -lh | numfmt --header --field 5 --from=iec --padding=10 $ ls -lh | numfmt --header --field 5 --from=iec --format %10f `, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(NumFmtCMDVersion) return nil } return nil }, }
NumFmtCMD define `numfmt` cmd
var PWDCMD = cli.Command{ Name: "pwd", Aliases: []string{"PWD"}, Usage: `打印当前/工作目录名称`, UsageText: `core pwd [command options]`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, &cli.BoolFlag{ Name: "logical", Aliases: []string{"L"}, Usage: `use PWD from environment, even if it contains symlinks`, }, &cli.BoolFlag{ Name: `physical`, Aliases: []string{"P"}, Value: true, Usage: `avoid all symlinks`, }, }, Action: func(c *cli.Context) (err error) { if c.Bool("version") { fmt.Println(c.Command.Name, PWDCMDVersion) return nil } if c.Bool("L") { fmt.Println(os.Getenv("PWD")) return err } pwd, err := os.Getwd() fmt.Println(pwd) return err }, }
PWDCMD define pwd cli command
var PWDCMDVersion = "v0.0.1"
PWDCMDVersion pwd version no
var PasteCMD = cli.Command{ Name: "paste", Aliases: []string{"PASTE"}, Usage: "合并文件文本行", Description: `Write lines consisting of the sequentially corresponding lines from each FILE, separated by TABs, to standard output. 如果没有指定文件,或者文件为"-",则从标准输入读取。`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(PasteCMDVersion) return nil } return nil }, }
PasteCMD define `paste` cmd
var PathChkCMD = cli.Command{ Name: "pathchk", Aliases: []string{"PATHCHK"}, Usage: "检查文件名是否有效或可移植", Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(PathChkCMDVersion) return nil } return nil }, }
PathChkCMD define `pathchk` cmd
var PrintEnvCMD = cli.Command{ Name: "printenv", Aliases: []string{"PRINTENV"}, Usage: `显示指定的环境变量的值。 如果没有指定变量,则打印出所有变量的名称和值。`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, &cli.BoolFlag{ Name: "null", Aliases: []string{"0"}, Usage: `end each output line with NUL, not newline`, }, }, Action: func(c *cli.Context) (err error) { if c.Bool("version") { fmt.Println(c.Command.Name, PrintEnvCMDVersion) return nil } end := "\n" if c.Bool("0") { end = "" } return PrintENV(end) }, }
PrintEnvCMD define printenv cli command
var PrintEnvCMDVersion = "v0.0.1"
PrintEnvCMDVersion printenv version no
var PtxCMD = cli.Command{ Name: "ptx", Aliases: []string{"PTX"}, Usage: "生成文件内容的排列索引", Description: `Output a permuted index, including context, of the words in the input files. 如果没有指定文件,或者文件为"-",则从标准输入读取。`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(PtxCMDVersion) return nil } return nil }, }
PtxCMD define `ptx` cmd
var RMCMD = cli.Command{ Name: "rm", Aliases: []string{"RM"}, Usage: "删除文件", Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: rmAction, }
RMCMD define rm cli command
var RMCMDVersion = "v0.0.1"
RMCMDVersion rm version no
var RealPathCMD = cli.Command{ Name: "realpath", Aliases: []string{"REALPATH"}, UsageText: "core realpath [选项]... 文件...", Usage: "打印已解析的路径[绝对地址]", Description: `Print the resolved absolute file name; all but the last component must exist 相较于原版,core realpath不进行文件是否存在的校验 `, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, &cli.BoolFlag{ Name: "canonicalize-existing", Aliases: []string{"e"}, Usage: "all components of the path must exist", }, &cli.BoolFlag{ Name: "canonicalize-missin", Aliases: []string{"m"}, Usage: "no path components need exist or be a directory", }, &cli.BoolFlag{ Name: "logical", Aliases: []string{"L"}, Usage: "resolve '..' components before symlinks", }, &cli.BoolFlag{ Name: "physical", Aliases: []string{"P"}, Usage: "resolve symlinks as encountered (default)", }, &cli.BoolFlag{ Name: "quiet", Aliases: []string{"q"}, Usage: "suppress most error messages", }, &cli.PathFlag{ Name: "relative-to", Usage: "print the resolved path relative to `DIR`", }, &cli.PathFlag{ Name: "relative-base", Usage: "print absolute paths unless paths below `DIR`", }, &cli.BoolFlag{ Name: "strip", Aliases: []string{"s"}, Usage: "don't expand symlinks", }, &cli.BoolFlag{ Name: "no-symlinks", Usage: "the same as --strip", }, &cli.BoolFlag{ Name: "zero", Aliases: []string{"z"}, Usage: "end each output line with NUL, not newline", }, }, Action: func(c *cli.Context) (err error) { if c.Bool("version") { fmt.Println(RealPathCMDVersion) return nil } if c.Args().Len() == 0 { cli.ShowCommandHelp(c, c.Command.Name) return fmt.Errorf("%s: 缺少操作数", c.Command.Name) } base := "/" end := "\n" if b := c.Path("relative-to"); b != "" { base = b } if c.Bool("zero") { end = "" } for _, p := range c.Args().Slice() { abs, _ := filepath.Abs(p) result, err := filepath.Rel(base, abs) if err != nil { return err } fmt.Printf("%s%s", result, end) } return err }, }
RealPathCMD define `realpath` cmd
var SeqCMD = cli.Command{ Name: "seq", Aliases: []string{"SEQ"}, UsageText: "core seq [选项]... 尾数\n\t core seq [选项]... 首数 尾数\n\t core seq [选项]... 首数 增量 尾数", Usage: "打印数字序列(暂时只支持整数)", Description: `Print numbers from FIRST to LAST, in steps of INCREMENT. If FIRST or INCREMENT is omitted, it defaults to 1. That is, an omitted INCREMENT defaults to 1 even when LAST is smaller than FIRST. The sequence of numbers ends when the sum of the current number and INCREMENT would become greater than LAST. FIRST, INCREMENT, and LAST are interpreted as floating point values. INCREMENT is usually positive if FIRST is smaller than LAST, and INCREMENT is usually negative if FIRST is greater than LAST. INCREMENT must not be 0; none of FIRST, INCREMENT and LAST may be NaN. FORMAT must be suitable for printing one argument of type 'double'; it defaults to %.PRECf if FIRST, INCREMENT, and LAST are all fixed point decimal numbers with maximum precision PREC, and to %g otherwise.`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, &cli.StringFlag{ Name: "format", Aliases: []string{"f"}, Usage: "use printf style floating-point FORMAT(尚未实现)", }, &cli.StringFlag{ Name: "separator", Aliases: []string{"s"}, Usage: "use `STRING` to separate numbers", Value: "\n", }, &cli.BoolFlag{ Name: "equal-width", Aliases: []string{"w"}, Usage: "equalize width by padding with leading zeroes(尚未实现)", }, }, Action: seqAction, }
SeqCMD define seq cli command
var SeqCMDVersion = "v0.0.1"
SeqCMDVersion seq version no
var ShredCMD = cli.Command{ Name: "shred", Aliases: []string{"SHRED"}, Usage: "覆盖文件以隐藏其内容,并可选择将其删除", Description: `Overwrite the specified FILE(s) repeatedly, in order to make it harder for even very expensive hardware probing to recover the data. If FILE is -, shred standard output. Delete FILE(s) if --remove (-u) is specified. The default is not to remove the files because it is common to operate on device files like /dev/hda, and those files usually should not be removed. The optional HOW parameter indicates how to remove a directory entry: 'unlink' => use a standard unlink call. 'wipe' => also first obfuscate bytes in the name. 'wipesync' => also sync each obfuscated byte to disk. The default mode is 'wipesync', but note it can be expensive. 警告:请注意使用shred 时有一个很重要的条件: 文件系统会在原来的位置覆盖指定的数据。传统的文件系统符合此条件,但许多现代 的文件系统都不符合条件。以下是会令shred 无效或不担保一定有效的文件系统的 例子: * 有纪录结构或是日志式文件系统,如AIX 及Solaris 使用的文件系统 (以及 JFS、ReiserFS、XFS、Ext3 等) * 会重复写入数据,及即使一部份写入动作失败后仍可继续的文件系统,如使用 RAID 的文件系统 * 会不时进行快照记录的文件系统,像Network Applicance 的NFS 服务器 * 文件系统是存放于缓存位置,比如NFS 第三版用户端 * 压缩文件系统 在Ext3 文件系统中,以上免责声明仅适用于启用了data=journal 模式的情况, 此时文件日志记录了附加的元数据 shred 的作用将受到影响。在data=ordered(默认) 或data=writeback 模式下shred 仍然有效。 Ext3 日志模式可通过向/etc/fstab 的挂载选项中添加data=something 进行设置, 您可以查看mount 的man 页面以获得详细信息。 另外,文件系统备份和远程镜像可能会 包含不能被删除的文件副本,这将会 允许碎片文件被恢复。`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(ShredCMDVersion) return nil } return nil }, }
ShredCMD define `shred` cmd
var ShufCMD = cli.Command{ Name: "shuf", Aliases: []string{"SHUF"}, Usage: "生成随机排列", Description: `Write a random permutation of the input lines to standard output. 如果没有指定文件,或者文件为"-",则从标准输入读取。`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并退出", }, &cli.BoolFlag{ Name: "echo", Aliases: []string{"e"}, Usage: "treat each ARG as an input line", }, &cli.StringFlag{ Name: "input-range", Aliases: []string{"i"}, Usage: "treat each number LO through HI as an input line(`LO-HI`)", }, &cli.PathFlag{ Name: "output", Aliases: []string{"o"}, Usage: "write result to `FILE` instead of standard output", }, &cli.PathFlag{ Name: "random-source", Usage: "get random bytes from `FILE`", }, &cli.BoolFlag{ Name: "repeat", Aliases: []string{"r"}, Usage: "output lines can be repeated", }, &cli.BoolFlag{ Name: "zero-terminated", Aliases: []string{"z"}, Usage: "line delimiter is NUL, not newline", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(ShufCMDVersion) return nil } return nil }, }
ShufCMD define `shuf` cmd
var SortCMD = cli.Command{ Name: "sort", Aliases: []string{"SORT"}, Usage: "排序文本文件的文本行", Description: `Write sorted concatenation of all FILE(s) to standard output. 如果没有指定文件,或者文件为"-",则从标准输入读取。 KEYDEF is F[.C][OPTS][,F[.C][OPTS]] for start and stop position, where F is a field number and C a character position in the field; both are origin 1, and the stop position defaults to the line's end. If neither -t nor -b is in effect, characters in a field are counted from the beginning of the preceding whitespace. OPTS is one or more single-letter ordering options [bdfgiMhnRrV], which override global ordering options for that key. If no key is given, use the entire line as the key. Use --debug to diagnose incorrect key usage. SIZE may be followed by the following multiplicative suffixes: % 1% of memory, b 1, K 1024 (default), and so on for M, G, T, P, E, Z, Y. *** WARNING *** The locale specified by the environment affects sort order. Set LC_ALL=C to get the traditional sort order that uses native byte values.`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(SortCMDVersion) return nil } return nil }, }
SortCMD define `sort` cmd
var SplitCMD = cli.Command{ Name: "split", Aliases: []string{"SPLIT"}, UsageText: "core split [OPTION]... [FILE [PREFIX]]", Usage: "文件分片", Description: `Output pieces of FILE to PREFIXaa, PREFIXab, ...; default size is 1000 lines, and default PREFIX is 'x'. 如果没有指定文件,或者文件为"-",则从标准输入读取。 The SIZE argument is an integer and optional unit (example: 10K is 10*1024). Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000). CHUNKS may be: N split into N files based on size of input K/N output Kth of N to stdout l/N split into N files without splitting lines/records l/K/N output Kth of N to stdout without splitting lines/records r/N like 'l' but use round robin distribution r/K/N likewise but only output Kth of N to stdout`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, &cli.IntFlag{ Name: "suffix-lengt", Aliases: []string{"a"}, Usage: "generate suffixes of length `N`", Value: 2, }, &cli.IntFlag{ Name: "bytes", Aliases: []string{"b"}, Usage: "put `SIZE` bytes per output file", }, &cli.IntFlag{ Name: "line-bytes", Aliases: []string{"C"}, Usage: "put at most `SIZE` bytes of records per output file ", }, &cli.BoolFlag{ Name: "d", Usage: "use numeric suffixes starting at 0, not alphabetic", }, &cli.IntFlag{ Name: "numeric-suffixes", Usage: "same as -d, but allow setting the start value", }, &cli.BoolFlag{ Name: "x", Usage: "use hex suffixes starting at 0, not alphabetic", }, &cli.StringFlag{ Name: "hex-suffixes", Usage: "same as -x, but allow setting the start value", }, &cli.BoolFlag{ Name: "elide-empty-files", Aliases: []string{"e"}, Usage: "do not generate empty output files with '-n'", }, &cli.StringFlag{ Name: "filter", Usage: "write to shell COMMAND; file name is $FILE", }, &cli.IntFlag{ Name: "lines", Aliases: []string{"l"}, Usage: "put `NUMBER` lines/records per output file", }, &cli.IntFlag{ Name: "numbers", Aliases: []string{"n"}, Usage: "generate `CHUNKS` output files; see explanation below", }, &cli.StringFlag{ Name: "separator", Aliases: []string{"t"}, Usage: "use `SEP` instead of newline as the record separator;`\\0` (zero) specifies the NUL character", }, &cli.BoolFlag{ Name: "unbuffered", Aliases: []string{"u"}, Usage: "immediately copy input to output with '-n r/...'", }, &cli.BoolFlag{ Name: "verbose", Usage: "在每个输出文件打开前输出文件特征", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(SplitCMDVersion) return nil } return nil }, }
SplitCMD define `split` cmd
var StatCMD = cli.Command{ Name: "stat", Aliases: []string{"STAT"}, Usage: "显示文件或文件系统状态", Description: `The valid format sequences for files (without --file-system): %a access rights in octal (note '#' and '0' printf flags) %A access rights in human readable form %b number of blocks allocated (see %B) %B the size in bytes of each block reported by %b %C SELinux security context string %d device number in decimal %D device number in hex %f raw mode in hex %F file type %g group ID of owner %G group name of owner %h number of hard links %i inode number %m mount point %n file name %N quoted file name with dereference if symbolic link %o optimal I/O transfer size hint %s total size, in bytes %t major device type in hex, for character/block device special files %T minor device type in hex, for character/block device special files %u user ID of owner %U user name of owner %w time of file birth, human-readable; - if unknown %W time of file birth, seconds since Epoch; 0 if unknown %x time of last access, human-readable %X time of last access, seconds since Epoch %y time of last data modification, human-readable %Y time of last data modification, seconds since Epoch %z time of last status change, human-readable %Z time of last status change, seconds since Epoch Valid format sequences for file systems: %a free blocks available to non-superuser %b total data blocks in file system %c total file nodes in file system %d free file nodes in file system %f free blocks in file system %i file system ID in hex %l maximum length of filenames %n file name %s block size (for faster transfers) %S fundamental block size (for block counts) %t file system type in hex %T file system type in human readable form 注意:您的shell 可能内置了自己的stat 程序版本,它会覆盖这里所提及的相应 版本。请查阅您的shell 文档获知它所支持的选项。 GNU coreutils online help: <http://www.gnu.org/software/coreutils/> 请向<http://translationproject.org/team/zh_CN.html> 报告stat 的翻译错误 Full documentation at: <http://www.gnu.org/software/coreutils/stat> or available locally via: info '(coreutils) stat invocation' ➜ core git:(master) ✗ stat core.go 文件:core.go 大小:1749 块:8 IO 块:4096 普通文件 设备:805h/2053d Inode:17340381 硬链接:1 权限:(0664/-rw-rw-r--) Uid:( 1000/ tacey) Gid:( 1000/ tacey) 最近访问:2020-11-25 10:50:06.913339128 +0800 最近更改:2020-11-25 10:50:06.857341765 +0800 最近改动:2020-11-25 10:50:06.857341765 +0800 创建时间:- ➜ core git:(master) ✗ stat --help 用法:stat [选项]... 文件... Display file or file system status. 必选参数对长短选项同时适用。 -L, --dereference follow links -f, --file-system display file system status instead of file status -c --format=FORMAT use the specified FORMAT instead of the default; output a newline after each use of FORMAT --printf=FORMAT like --format, but interpret backslash escapes, and do not output a mandatory trailing newline; if you want a newline, include \n in FORMAT -t, --terse print the information in terse form --help 显示此帮助信息并退出 --version 显示版本信息并退出 The valid format sequences for files (without --file-system): %a access rights in octal (note '#' and '0' printf flags) %A access rights in human readable form %b number of blocks allocated (see %B) %B the size in bytes of each block reported by %b %C SELinux security context string %d device number in decimal %D device number in hex %f raw mode in hex %F file type %g group ID of owner %G group name of owner %h number of hard links %i inode number %m mount point %n file name %N quoted file name with dereference if symbolic link %o optimal I/O transfer size hint %s total size, in bytes %t major device type in hex, for character/block device special files %T minor device type in hex, for character/block device special files %u user ID of owner %U user name of owner %w time of file birth, human-readable; - if unknown %W time of file birth, seconds since Epoch; 0 if unknown %x time of last access, human-readable %X time of last access, seconds since Epoch %y time of last data modification, human-readable %Y time of last data modification, seconds since Epoch %z time of last status change, human-readable %Z time of last status change, seconds since Epoch Valid format sequences for file systems: %a free blocks available to non-superuser %b total data blocks in file system %c total file nodes in file system %d free file nodes in file system %f free blocks in file system %i file system ID in hex %l maximum length of filenames %n file name %s block size (for faster transfers) %S fundamental block size (for block counts) %t file system type in hex %T file system type in human readable form`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, &cli.BoolFlag{ Name: "dereference", Aliases: []string{"L"}, Usage: "follow links", }, &cli.BoolFlag{ Name: "file-system", Aliases: []string{"f"}, Usage: "display file system status instead of file status", }, &cli.StringFlag{ Name: "--format", Aliases: []string{"c"}, Usage: `use the specified FORMAT instead of the default; output a newline after each use of FORMAT`, }, &cli.StringFlag{ Name: "printf", Usage: `like --format, but interpret backslash escapes, and do not output a mandatory trailing newline; if you want a newline, include \n in FORMAT `, }, &cli.BoolFlag{ Name: "terse", Aliases: []string{"t"}, Usage: " print the information in terse form", }, }, Action: statAction, }
StatCMD define stat cli command
var StatCMDVersion = "v0.0.1"
StatCMDVersion stat version no
var SyncCMD = cli.Command{ Name: "sync", Aliases: []string{"SYNC"}, Usage: "同步缓存写到持久存储", Description: `If one or more files are specified, sync only them, or their containing file systems.`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(SyncCMDVersion) return nil } return nil }, }
SyncCMD define `sync` cmd
var TSortCMD = cli.Command{ Name: "tsort", Aliases: []string{"TSORT"}, Usage: "执行拓扑排序", Description: `Write totally ordered list consistent with the partial ordering in FILE. 如果没有指定文件,或者文件为"-",则从标准输入读取。`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(TSortCMDVersion) return nil } return nil }, }
TSortCMD define `tsort` cmd
var TailCMD = cli.Command{ Name: "tail", Aliases: []string{"TAIL"}, Usage: "打印文本文件的最后10行到标准输出", Description: `With more than one FILE, precede each with a header giving the file name. 如果没有指定文件,或者文件为"-",则从标准输入读取。 NUM may have a multiplier suffix: b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024, GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y. 如果您希望即时追查一个文件的有效名称而非描述内容(例如循环日志),默认 的程序动作并不如您所愿。在这种场合可以使用--follow=name 选项,它会使 tail 定期追踪打开给定名称的文件,以确认它是否被删除或被其它某些程序重新创建过。`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, &cli.IntFlag{ Name: "bytes", Aliases: []string{"c"}, Usage: "output the last NUM bytes; or use -c +NUM to output starting with byte NUM of each file", }, &cli.BoolFlag{ Name: "follow", Aliases: []string{"f"}, Usage: "output appended data as the file grows'", }, &cli.BoolFlag{ Name: "follow-at", Aliases: []string{"x"}, Usage: "output appended data as the file grows; an absent option argument means '`descriptor`'", }, &cli.BoolFlag{ Name: "F", Usage: "same as --follow-at=name --retry", }, &cli.StringFlag{ Name: "lines", Aliases: []string{"n"}, Usage: "output the last NUM lines, instead of the last 10;or use -n +NUM to output starting with line NUM", }, &cli.IntFlag{ Name: "max-unchanged-stats", Value: 5, Usage: "with --follow=name, reopen a FILE which has not" + "changed size after `N` (default 5) iterations" + "to see if it has been unlinked or renamed" + "(this is the usual case of rotated log files);" + "with inotify, this option is rarely useful", }, &cli.IntFlag{ Name: "pid", Usage: "with -f, terminate after process ID, PID dies", }, &cli.BoolFlag{ Name: "quiet", Aliases: []string{"q"}, Usage: "never output headers giving file names", }, &cli.BoolFlag{ Name: "silent", Usage: "same as --quiet", }, &cli.BoolFlag{ Name: "retry", Usage: "keep trying to open a file if it is inaccessible", }, &cli.Float64Flag{ Name: "sleep-interval", Aliases: []string{"s"}, Value: 1.0, Usage: "with -f, sleep for approximately `N` seconds between iterations" + "with inotify and --pid=P, check process P at least once every N seconds", }, &cli.BoolFlag{ Name: "verbose", Aliases: []string{"V"}, Usage: "always output headers giving file names", }, &cli.BoolFlag{ Name: "zero-terminated", Aliases: []string{"z"}, Usage: "line delimiter is NUL, not newline", }, }, Action: func(c *cli.Context) (err error) { if c.Bool("version") { fmt.Println(TailCMDVersion) return nil } fmt.Println(c.FlagNames()) return err }, }
TailCMD define `tail` command
var TeeCMD = cli.Command{ Name: "tee", Aliases: []string{"TEE"}, Usage: "标准输入复制到每个指定文件,并显示到标准输出。", Description: `MODE determines behavior with write errors on the outputs: 'warn' diagnose errors writing to any output 'warn-nopipe' diagnose errors writing to any output not a pipe 'exit' exit on error writing to any output 'exit-nopipe' exit on error writing to any output not a pipe The default MODE for the -p option is 'warn-nopipe'. The default operation when --output-error is not specified, is to exit immediately on error writing to a pipe, and diagnose errors writing to non pipe outputs.`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(TeeCMDVersion) return nil } return nil }, }
TeeCMD define `tee` cmd
var TestCMD = cli.Command{ Name: "test", Aliases: []string{"TEST"}, Usage: "检查文件类型并比较值", Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(TestCMDVersion) return nil } return nil }, }
TestCMD define `test` cmd
var TimeoutCMD = cli.Command{ Name: "timeout", Aliases: []string{"TIMEOUT"}, Usage: "有时间限制地运行命令", Description: `DURATION is a floating point number with an optional suffix: 's' for seconds (the default), 'm' for minutes, 'h' for hours or 'd' for days. If the command times out, and --preserve-status is not set, then exit with status 124. Otherwise, exit with the status of COMMAND. If no signal is specified, send the TERM signal upon timeout. The TERM signal kills any process that does not block or catch that signal. It may be necessary to use the KILL (9) signal, since this signal cannot be caught, in which case the exit status is 128+9 rather than 124.`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(TimeoutCMDVersion) return nil } return nil }, }
TimeoutCMD define `timeout` cmd
var TouchCMD = cli.Command{ Name: "touch", Aliases: []string{"TOUCH"}, UsageText: "core touch [选项]... 文件...", Usage: `更改文件时间戳`, Description: `Update the access and modification times of each FILE to the current time. A FILE argument that does not exist is created empty, unless -c or -h is supplied. A FILE argument string of - is handled specially and causes touch to change the times of the file associated with standard output. 请注意,-d 和-t 选项可接受不同的时间/日期格式。`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, &cli.BoolFlag{ Name: "access", Aliases: []string{"a"}, Usage: `只更改访问时间`, }, &cli.BoolFlag{ Name: "no-create", Aliases: []string{"c"}, Usage: `不创建任何文件`, }, &cli.StringFlag{ Name: "date", Aliases: []string{"d"}, Usage: `使用指定字符串表示时间而非当前时间`, }, &cli.BoolFlag{ Name: "no-dereference", Aliases: []string{"nd"}, Usage: `会影响符号链接本身,而非符号链接所指示的目的地 (当系统支持更改符号链接的所有者时,此选项才有用)[尚未实现]`, }, &cli.BoolFlag{ Name: "modify", Aliases: []string{"m"}, Usage: `只更改修改时间`, }, &cli.PathFlag{ Name: "reference", Aliases: []string{"r"}, Usage: `use this file's times instead of current time`, }, &cli.StringFlag{ Name: "time", Usage: `change the specified time: WORD is access, atime, or use: equivalent to -a WORD is modify or mtime: equivalent to -m 【尚未实现】`, }, &cli.BoolFlag{ Name: "STAMP", Aliases: []string{"s"}, Usage: `use [[CC]YY]MMDDhhmm[.ss] instead of current time【尚未实现】`, }, }, Action: touchAction, }
TouchCMD define touch cli command
var TouchCMDVersion = "v0.0.1"
TouchCMDVersion touch version no
var TrCMD = cli.Command{ Name: "tr", Aliases: []string{"TR"}, Usage: "转换或删除字符", Description: `Translate, squeeze, and/or delete characters from standard input, writing to standard output. SET 是一组字符串,一般都可按照字面含义理解。解析序列如下: \NNN 八进制值为NNN 的字符(1 至3 个数位) \\ 反斜杠 \a 终端鸣响 \b 退格 \f 换页 \n 换行 \r 回车 \t 水平制表符 \v 垂直制表符 字符1-字符2 从字符1 到字符2 的升序递增过程中经历的所有字符 [字符*] 在SET2 中适用,指定字符会被连续复制直到吻合设置1 的长度 [字符*次数] 对字符执行指定次数的复制,若次数以 0 开头则被视为八进制数 [:alnum:] 所有的字母和数字 [:alpha:] 所有的字母 [:blank:] 所有呈水平排列的空白字符 [:cntrl:] 所有的控制字符 [:digit:] 所有的数字 [:graph:] 所有的可打印字符,不包括空格 [:lower:] 所有的小写字母 [:print:] 所有的可打印字符,包括空格 [:punct:] 所有的标点字符 [:space:] 所有呈水平或垂直排列的空白字符 [:upper:] 所有的大写字母 [:xdigit:] 所有的十六进制数 [=字符=] 所有和指定字符相等的字符 Translation occurs if -d is not given and both SET1 and SET2 appear. -t may be used only when translating. SET2 is extended to length of SET1 by repeating its last character as necessary. Excess characters of SET2 are ignored. Only [:lower:] and [:upper:] are guaranteed to expand in ascending order; used in SET2 while translating, they may only be used in pairs to specify case conversion. -s uses the last specified SET, and occurs after translation or deletion.`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(TrCMDVersion) return nil } return nil }, }
TrCMD define `tr` cmd
var TrueCMD = cli.Command{ Name: "true", Aliases: []string{"TRUE"}, Usage: "什么都不做,成功执行空白进程", Description: "会返回一个状态码表示成功执行", Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(TrueCMDVersion) return nil } return nil }, }
TrueCMD define `true` command
var TruncateCMD = cli.Command{ Name: "truncate", Aliases: []string{"TRUNCATE"}, Usage: "缩小或扩展文件的大小到指定的大小", Description: `A FILE argument that does not exist is created. If a FILE is larger than the specified size, the extra data is lost. If a FILE is shorter, it is extended and the extended part (hole) reads as zero bytes. The SIZE argument is an integer and optional unit (example: 10K is 10*1024). Units are K,M,G,T,P,E,Z,Y (powers of 1024) or KB,MB,... (powers of 1000). SIZE may also be prefixed by one of the following modifying characters: '+' extend by, '-' reduce by, '<' at most, '>' at least, '/' round down to multiple of, '%' round up to multiple of.`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, &cli.BoolFlag{ Name: "no-create", Aliases: []string{"c"}, }, &cli.BoolFlag{ Name: "io-blocks", Aliases: []string{"o"}, Usage: "将SIZE 视为IO 块数而不使用字节数", }, &cli.PathFlag{ Name: "reference", Aliases: []string{"r"}, Usage: "base size on `RFILE`", }, &cli.IntFlag{ Name: "size", Aliases: []string{"s"}, Usage: "set or adjust the file size by `SIZE` bytes", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(TruncateCMDVersion) return nil } return nil }, }
TruncateCMD define `truncate` cmd
var TtyCMD = cli.Command{ Name: "tty", Aliases: []string{"TTY"}, Usage: `显示出连接到当前标准输入的终端设备文件名。`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, &cli.BoolFlag{ Name: "silent", Aliases: []string{"s"}, Usage: "什么也不显示,只返回退出状态值", }, &cli.BoolFlag{ Name: "quiet", Usage: "同--silent", }, }, Action: ttyAction, }
TtyCMD define tty cli command
var TtyCMDVersion = "v0.0.1"
TtyCMDVersion tty version no
var UNameCMD = cli.Command{ Name: "uname", Aliases: []string{"UNAME"}, Usage: "打印系统信息", Description: `Print certain system information. With no OPTION, same as -s.`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"V"}, Usage: "输出版本信息并推出", }, &cli.BoolFlag{ Name: "all", Aliases: []string{"a"}, Usage: "以如下次序输出所有信息。其中若-p 和 -i 的探测结果不可知则被省略:", }, &cli.BoolFlag{ Name: "kernel-name", Aliases: []string{"s"}, Usage: "输出内核名称", }, &cli.BoolFlag{ Name: "nodename", Aliases: []string{"n"}, Usage: "输出网络节点上的主机名", }, &cli.BoolFlag{ Name: "kernel-release", Aliases: []string{"r"}, Usage: "输出内核发行号", }, &cli.BoolFlag{ Name: "kernel-version", Aliases: []string{"v"}, Usage: "输出内核版本", }, &cli.BoolFlag{ Name: "machine", Aliases: []string{"m"}, Usage: "输出机器硬件名称", }, &cli.BoolFlag{ Name: "processor", Aliases: []string{"p"}, Usage: "输出处理器类型(non-portable)", }, &cli.BoolFlag{ Name: "hardware-platform", Aliases: []string{"i"}, Usage: "输出硬件平台(non-portable)", }, &cli.BoolFlag{ Name: "operating-system", Aliases: []string{"o"}, Usage: "输出操作系统", }, &cli.BoolFlag{ Name: "pretty", Usage: "美化输出", }, }, Action: Uname, }
UNameCMD define `uname` cli command
var UnExpandCMD = cli.Command{ Name: "unexpand", Aliases: []string{"UNEXPAND"}, Usage: "空格转换成制表符", Description: `Convert blanks in each FILE to tabs, writing to standard output. 如果没有指定文件,或者文件为"-",则从标准输入读取。`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(UnExpandCMDVersion) return nil } return nil }, }
UnExpandCMD define `unexpand` cmd
var UniqCMD = cli.Command{ Name: "uniq", Aliases: []string{"UNIQ"}, Usage: `报告或省略重复的行`, Description: `Filter adjacent matching lines from INPUT (or standard input), writing to OUTPUT (or standard output) Note: 'uniq' does not detect repeated lines unless they are adjacent. You may want to sort the input first, or use 'sort -u' without 'uniq'. Also, comparisons honor the rules specified by 'LC_COLLATE'.`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(TrueCMDVersion) return nil } return nil }, }
UniqCMD define `uniq` cmd
var UptimeCMD = cli.Command{ Name: "uptime", Aliases: []string{"UPTIME"}, Usage: "显示系统运行了多长时间", Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "output this help information and exit", }, &cli.BoolFlag{ Name: "pretty", Aliases: []string{"p"}, Usage: "show uptime in pretty format", }, &cli.StringFlag{ Name: "since", Aliases: []string{"s"}, Usage: "system up since", }, }, Action: uptimeAction, }
UptimeCMD define uptime cli command
var UptimeCMDVersion = "v0.0.1"
UptimeCMDVersion uptime version no
var UsersCMD = cli.Command{ Name: "users", Aliases: []string{"USERS"}, Usage: `根据文件判断输出当前有谁正登录在系统上。 如果文件未予指定,则使用/var/run/utmp,/var/log/wtmp 是通用的相关文件`, Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: usersAction, }
UsersCMD define users cli command
var UsersCMDVersion = "v0.0.1"
UsersCMDVersion users version no
var YesCMD = cli.Command{ Name: "yes", Aliases: []string{"YES"}, Usage: "重复输出一个字符串直到被kill", Flags: []cli.Flag{ &cli.BoolFlag{ Name: "version", Aliases: []string{"v"}, Usage: "输出版本信息并推出", }, }, Action: func(c *cli.Context) error { if c.Bool("version") { fmt.Println(TrueCMDVersion) return nil } strContent := "y" if c.Args().Get(0) != "" { strContent = c.Args().Get(0) } for { fmt.Println(strContent) } }, }
YesCMD define `yes` cmd
Functions ¶
Types ¶
Source Files
¶
- arch.go
- base32.go
- base64.go
- basename.go
- cat.go
- chgrp.go
- chmod.go
- chown.go
- chroot.go
- cksum.go
- comm.go
- cp.go
- csplit.go
- cut.go
- date.go
- dd.go
- df.go
- dirname.go
- du.go
- env.go
- expand.go
- expr.go
- factor.go
- false.go
- groups.go
- head.go
- hostid.go
- hostname.go
- id.go
- join.go
- logname..go
- lscpu.go
- mktemp.go
- mv.go
- nice.go
- nl.go
- nproc.go
- numfmt.go
- paste.go
- pathchk.go
- printenv.go
- ptx.go
- pwd.go
- realpath.go
- rm.go
- seq.go
- shred.go
- shuf.go
- sort.go
- split.go
- stat.go
- sync.go
- tail.go
- tee.go
- test.go
- timeout.go
- touch.go
- tr.go
- true.go
- truncate.go
- tsort.go
- tty.go
- uname.go
- unexpand.go
- uniq.go
- uptime.go
- users.go
- yes.go