码迷,mamicode.com
首页 > 系统相关 > 详细

linux 命令学习1

时间:2019-01-30 01:27:56      阅读:217      评论:0      收藏:0      [点我收藏+]

标签:空格   which   list   chm   step   inf   换行   each   ret   

 tr命令

NAME
       tr - translate or delete characters

SYNOPSIS
       tr [OPTION]... SET1 [SET2]

DESCRIPTION
       Translate, squeeze, and/or delete characters from standard input, writing to standard output.

       -c, -C, --complement
              use the complement of SET1

       -d, --delete
              delete characters in SET1, do not translate

       -s, --squeeze-repeats
              replace each sequence of a repeated character that is listed  in
              the last specified SET, with a single occurrence of that charac\u2010
              ter

       -t, --truncate-set1
              first truncate SET1 to length of SET2

       --help display this help and exit

       --version
              output version information and exit

       SETs are specified as strings  of  characters.   Most  represent  them
       selves.  Interpreted sequences are:

       \NNN   character with octal value NNN (1 to 3 octal digits)

       \\     backslash

       \a     audible BEL

       \b     backspace

       \f     form feed

       \n     new line

       \r     return

       \t     horizontal tab

       \v     vertical tab
eg技术分享图片将 从标准输入的字符把 a替换成b 重定向到cmdlist.txt 文件中(Ctrl+z 停止输入字符)

任务: 分别计算上述命令的MAN文档的行数

         STEP1:  将上述命令放置到一个文本文件中, 命令为 cmds.list  

技术分享图片
ls, cp, rm , mv,  cat , head, tail ,  cd ,  pwd, mkdir ,  touch,  rename,  less,  find, which, locate,  chmod, chown, less, ln,  tar,  umask
 grep, sed, awk, tr,  uniq,  sort,  join,  cut,  tee,  wc, 
ps,  top,  fg,  kill,   who,  
netstat ,  scp ,   ssh,  ping,   wget
set,  alias, . ,  source, sudo ,  su,  date, 
 man ,
xargs  
技术分享图片

          STEP2:使用 tr 命令先将 ,  转化为 换行,并去掉空格和空行; 

             $ tr ‘,‘ ‘\n‘ < cmds.list | tr -d ‘ ‘ | grep -v ‘^$‘ > result.mid

           (grep -v ‘^$‘意思是取非空行的行,‘^$’为正则表达式)

       step3及实验结果待续

参考:开发人员的 Linux 命令学习清单

        

 

linux 命令学习1

标签:空格   which   list   chm   step   inf   换行   each   ret   

原文地址:https://www.cnblogs.com/cai-cai777/p/10336407.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!