Practical unix utilities for text processing
Upcoming SlideShare
Loading in...5
×
 

Practical unix utilities for text processing

on

  • 7,506 views

 

Statistics

Views

Total Views
7,506
Views on SlideShare
3,226
Embed Views
4,280

Actions

Likes
13
Downloads
107
Comments
0

47 Embeds 4,280

http://arhipov.blogspot.com 2969
http://www.devclub.eu 422
http://arhipov.blogspot.in 183
http://arhipov.blogspot.de 119
http://arhipov.blogspot.co.uk 95
http://feeds.feedburner.com 80
http://arhipov.blogspot.fr 47
http://arhipov.blogspot.ca 30
http://arhipov.blogspot.com.es 28
http://arhipov.blogspot.com.au 26
http://arhipov.blogspot.it 23
http://arhipov.blogspot.se 22
http://arhipov.blogspot.com.br 21
http://arhipov.blogspot.cz 20
http://arhipov.blogspot.nl 19
http://arhipov.blogspot.ru 18
http://arhipov.blogspot.no 15
http://arhipov.blogspot.co.il 13
http://arhipov.blogspot.ch 11
http://arhipov.blogspot.jp 10
http://arhipov.blogspot.co.at 9
http://arhipov.blogspot.be 8
http://arhipov.blogspot.dk 8
http://arhipov.blogspot.mx 7
http://arhipov.blogspot.sg 7
http://arhipov.blogspot.kr 6
http://www.linkedin.com 6
http://arhipov.blogspot.hk 6
http://arhipov.blogspot.pt 6
http://arhipov.blogspot.co.nz 5
http://arhipov.blogspot.com.ar 4
http://arhipov.blogspot.hu 4
http://arhipov.blogspot.tw 4
http://arhipov.blogspot.fi 4
http://webcache.googleusercontent.com 4
http://www.arhipov.blogspot.com 4
http://arhipov.blogspot.ro 3
http://www.hanrss.com 2
http://arhipov.blogspot.sk 2
http://arhipov.blogspot.ie 2
http://translate.googleusercontent.com 2
http://arhipov.blogspot.gr 1
http://paper.li 1
http://www.arhipov.blogspot.ru 1
http://feedproxy.google.com 1
http://reader.aol.com 1
http://localhost 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Practical unix utilities for text processing Practical unix utilities for text processing Presentation Transcript

    • grep | sed | awk | xargs | etc
      Practical *nix utilities(for text processing)
    • whoami
    • /
      awk
      cat
      grep
      tac
      sed
      echo
      ls
      du
      test
      mv
      split
      tail
      dir
      join
      wc
      head
      vim
      tr
      sort
      sum
      cut
      expr
      uniq
      paste
      kill
      tee
    • /
      Log
      Mega App
      Files
      DB
    • pwd | ls | find | tee
      GNU
      Coreutils
      http://www.gnu.org/software/coreutils/
      The takeaway command:man
      > info coreutils
    • pwd | ls | find | tee
      List of files:
      ls –l
      ls–1
      ls –latr
      find . –name *.txt
    • pwd | ls | find | tee
      Seek for a string in a file:
      grep“cat” file.txt
      grep –v “dog” file.txt
      grep –i “PaTtErN” file.txt
      egrep“cat|dog” file.txt
      zgrep“cat” file.txt.gz
    • for / xargs
      Do something with each file:
      for file in `find . –name *tmp`
      do
      rm$file
      done
      find . –name *tmp| xargsrm
    • pwd | ls | find | tee
      find + grep
      find . -name '*txt' -exec grep-l aaa{} ;
      find . -name '*txt' | xargsgrep-l aaa
    • pwd | ls | find | tee
      cat
      grep
      tac
      echo
      ls
      du
      test
      mv
      split
      tail
      dir
      join
      wc
      head
      tr
      sort
      sum
      cut
      expr
      uniq
      paste
      kill
      tee
    • paste
    • join
    • sort | uniq
    • wc
    • cut
    • csplit
    • awk
      sed
    • sed
      sfor substitution
      sed‘s/cat/dog/’
      # cat -> dog
      sed ‘s/(a)(b)/21/’
      # ab-> ba
    • sed
      pfor printing
      sed –n ‘/dog/p’
      # print lines that match ‘dog’
      sed–n ‘/start/,/end/p’
      # print range
    • sed
      dto delete
      sed ‘/dog/d’
      # delete lines that match ‘dog’
      sed ‘1,/pattern/d’
      # delete range
    • sed
      | and –e for invocation
      sed ‘s/a/A/’ | sed ‘s/b/B/’
      #
      sed –e ‘s/a/A/’ –e ‘s/b/B/’
      #
    • sed
      { .. } to group the commands
      sed ‘/pattern/ {
      s/p/P/
      s/e/E/
      }’
      #pattern -> PattErn
    • sed
      rto read a file
      sed ‘/include/ r file.txt’
      # insert file.txt after include
      wto write to a file
      sed‘/pattern/ w file.txt’
      # write matched lines to a file
    • sedtris
    • awk
      aaabbb ccc
      aaabbbzzz
      awk '/zzz/' 1.txt
      grepzzz 1.txt
      aaabbbzzz
    • awk
      awk
      'BEGIN{<initializations>}
      <pattern 1> {<actions>}
      <pattern 2> {<actions>}
      ...
      END{<final actions>}'
    • awk
      awk
      'BEGIN{a=0, b=0}
      /aaa/{a++}
      /bbb/ {b++}
      END{printf “%d %d”,a,b}'
    • awk
      awk
      '{arr[$2]+=$1}
      END
      { for (id in arr)
      printf "%s %d ",id,arr[id]}'
    • exit
      @antonarhipov