-
Notifications
You must be signed in to change notification settings - Fork 0
Some Unix Commands
Ben Chen edited this page Jul 21, 2017
·
6 revisions
Table of Contents generated with DocToc
鳥哥的 Linux 私房菜 -- 第十章、認識與學習BASH
file 参数用 - 表示使用标准输入/输出
行内切割
cut -d '分隔符' -f fields
#fields: 第几个(eg. 1 1,3 12-)
cut -c 字符区间
#取出列区间内容
搜索取出行
grep [-acinv] [--color=auto] '搜索串' filename
-a: treat binary as text
-c: 计算次数
-i: 忽略大小写
-n: 带行号输出
-v: 反向选择
--color=auto: 关键字加颜色
排序
sort [-fbMnrtuk] [file or stdin]
-f: 忽略大小写
-b: 忽略行首空格
-M: 月份名字排序(eg. JAN, DEC)
-n: 数字排序(整个数从小到大)
-r: 反向排序
-u: 除去重复 (uniq)
-t: 分隔符(默认为tab)
-k: 排序序号区间(与-t配合使用)
eg.
sort -t ':' -k 3 #按照以‘:’分割的第三列及其后排序
sort -t ':' -k 3,3 #按照以‘:’分割的第三列排序
除重(只处理相邻的行,所以要先排好序)
uniq [-ic]
-i: 忽略大小写
-c: 计数
统计行、字数(单词数)、字符数
wc [-lwm]
-l: 行数
-w: 字数(单词数,words)
-m: 字符数
除输出到屏幕外,多输出一份到文件里
tee [-a] file
-a: append
usage: last | tee last.list
stdin ➡️ tee ➡️ stdout
⬇️
file
删除/替换
tr [-ds] SET1 ...
-d: 删除 SET1 匹配的内容
-s: 替换重复字符 SET1 为单个 SET2
tab 换成空格
col [-xb]
-x: tab 换成空格(一般8个)
expand [t] file
-t: 每个 tab 换成多少空格
(unexpand: 把空格换成 tab)
按分隔符分隔,对比指定的栏,两个文件相同的就连成一行(用于对比的栏会移到第一栏)(要先排序)
join [-ti12] file1 file2
-t: 分隔符(默认空格)
-i: 忽略大小写
-1: 用第一个文件的哪一栏来对比
-2: 用第二个文件的哪一栏来对比
直接每行拼起来,默认用tab分隔
paste [-d] file1 file2
-d: 分隔符
把大文件分割成小文件(按大小或行数)
split [-bl] file PREFIX
-b: 按文件大小分割
-l: 按行数分割
PREFIX: 分割后文件名的前导字符
(合并档案:cat PREFIX* >> PREFIXwhole)
从标准输入产生命令的参数来调用命令
(很多指令其實並不支援管線命令,因此我們可以透過 xargs 來提供該指令引用 standard input 之用!)
xargs [-0epn] command
-0: 还原特殊字符(如`,\,空格等)
-e: EOF,当遇到这个字符串时停止
-p: prompt
-n: 每次传参数的个数(按照这个参数数量多次调用命令)
-
-
Overview
- Terminoloty
- Overall Procedure
-
Procedure
- Data Preperation
- Dictionay Preperation
- Extract MFCC features
- Train monophone models
- Align audio with the acoustic models
- Train triphone models
- Re-align audio with the acoustic models & re-train triphone models
- Kaldi DNN Simple Notes
-
Overview