Coder Social home page Coder Social logo

comp9044-19t2's Introduction

COMP9044-19T2

Software Construction

LAB 01

Shell 正则表达式(BRE)

  • ? 表示前面的字符可以出现0次或1次,匹配成立

  • | 表示 or

  • + 表示前面的字符可以出现1次或者多次,但必须出现至少1次

    • '([0-9]+,)*'

      • 2,4,8,16,32
  • u* 表示字母u可能出现或者不出现的匹配模式的文本中

  • 且如果出现前有多个字符的情况AB*只表示B可能出现或者不出现

(在字符后面放置星号标明该字符必须在匹配模式的版本中出现0次或者多次)

cat

  • -n number output lines (starting from 1) 输出多少行
  • -s squeeze consecutive blank lines into single blank line 将连续的空白行压缩成一行空白行
  • -v display control-characters in visiable form

wc

  • -c counts the number of characters (include "." )
  • -w count the number of words(non-white space)
  • -l count the number of lines

tr

tr ’sourceChars’ ’destChars’ < dataFile

将dataFile 里面的’sourceChars’替换成’destChars’

  • -c map all characters not occurring in sourceChars
  • -s squeeze adjacent repeated characters out(only copy the first)
  • -d delete all characters in sourceChars
    • Example
      • tr -cs ’a-zA-Z0-9’ ’\n’ < text (break text file into individual words, one per line)

head/tail

  • -n 前/后n行

egrep

  • -i ignore upper/lower-case difference in matching
  • -v only display lines that do not match the pattern
  • -w only match pattern if it makes a complete word

egrep其实就是grep的扩展版

  • grep -P Perl-like extended regular expressions

    • Lab01 question中有一道题利用此条命令

      • grep -P '^(A(?1)?B)$' input.txt (AABB)

cut

  • -f print only the specificed filed
  • -c print only chars in the specificed filed
  • -d'c' use character c as the filed separator
    • cut -f4- 两个杠表示 print all colums after the third

sort

  • -r sort in descending order (reverse sort) sort

  • -n numerically rather than lexicographically dictionary

  • -dorder: ignore non-letters and non-digits use character

  • -t’c’ c to separate columns (default: space)

  • -kn’sort on column n

uniq

  • -c print number of times each line is duplicated
  • -d only print duplicated line
  • -u only print lines that occur uniquely(once only)

xargs

  • remove home directories of users named Andrew:

    -grep Andrew /etc/passwd | cut -d: -f6 | xargs rm -r - 1. 通过grep /etc/passwd 中的关键字 - 2. 在通过cut来获取关键字后的路径 - 3. 删除路径中的文件

join

  • join -a 1 P.txt Q.txt
    • Print non pairable lines from first file.
      • 打印出不同的

matcher

  1. tr -d '[]"#'
    • delete []"# in the string

comp9044-19t2's People

Contributors

us579 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.