Daniel Carneiro Shell Script Parte V
Funções para arquivos <ul><li>basename  – strip directory </li><ul><li>basename  /home/daniel/a.txt a.txt
basename  /home/daniel/a.txt .txt a </li></ul><li>dirname  – strip filename </li><ul><li>dirname  /home/daniel/a.txt /home...
dirname  a.txt . </li></ul></ul>
<ul><li>readlink  – read symbolic link </li><ul><li>readlink   Downloads  (link) /mnt/Downloads
readlink  a.txt
readlink  -f a.txt /home/daniel/a.txt </li></ul></ul>
<ul><li>cksum  – CRC Sum </li><ul><li>cksum   a.txt 3008846902 118 a.txt </li></ul><li>md5sum  – MD5 Sum </li><ul><li>md5s...
md5sum   -c  md5.txt </li></ul><li>sha1sum  – SHA1 Sum </li><ul><li>sha1sum   a.txt 9772e92de67bc30de5aa34fd250c65ceb182e2...
sha1sum   -c  sha1.txt </li></ul></ul>
Funções para arquivos texto <ul><li>cat  – concatenate </li><ul><li>cat   a.txt b.txt  >  c.txt </li></ul><li>tac  – conca...
<ul><li>nl  – number lines </li><ul><li>nl   a.txt   1  texto x   2  texto y   3  texto z </li></ul><li>fold  – limit widt...
tail   -f  a.log </li></ul></ul>
<ul><li>split  – split file into pieces </li><ul><li>split   -l 20  a.txt  arq. </li><ul><li>arq.aa, arq.ab, arq.ac …
-l lines, -c bytes </li></ul></ul><li>wc  – word count </li><ul><li>wc   -l  a.txt </li><ul><li>-l -> lines
-c -> bytes
-m -> chars
Upcoming SlideShare
Loading in …5
×

Shell Scripting

931 views

Published on

Quinta parte da apresentação sobre Shell Scripting realizada na Bluesoft

Confira o video em http://www.vimeo.com/bluesoft

Published in: Technology
2 Comments
0 Likes
Statistics
Notes
  • @fabioarz O vídeo ? Corrigi o link, mas tem que buscar o vídeo no canal da Bluesoft.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Bom dia, porque vc nao disponibiliza seu material?
    abs
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

No Downloads
Views
Total views
931
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
0
Comments
2
Likes
0
Embeds 0
No embeds

No notes for slide
  • else = default = *) ;;* Shell pattern
  • else = default = *) ;;* Shell pattern
  • Shell Scripting

    1. 1. Daniel Carneiro Shell Script Parte V
    2. 2. Funções para arquivos <ul><li>basename – strip directory </li><ul><li>basename /home/daniel/a.txt a.txt
    3. 3. basename /home/daniel/a.txt .txt a </li></ul><li>dirname – strip filename </li><ul><li>dirname /home/daniel/a.txt /home/daniel
    4. 4. dirname a.txt . </li></ul></ul>
    5. 5. <ul><li>readlink – read symbolic link </li><ul><li>readlink Downloads (link) /mnt/Downloads
    6. 6. readlink a.txt
    7. 7. readlink -f a.txt /home/daniel/a.txt </li></ul></ul>
    8. 8. <ul><li>cksum – CRC Sum </li><ul><li>cksum a.txt 3008846902 118 a.txt </li></ul><li>md5sum – MD5 Sum </li><ul><li>md5sum a.txt 32c30735bc18fbd2252768f4f3f7f88d a.txt
    9. 9. md5sum -c md5.txt </li></ul><li>sha1sum – SHA1 Sum </li><ul><li>sha1sum a.txt 9772e92de67bc30de5aa34fd250c65ceb182e2a9 a.sql
    10. 10. sha1sum -c sha1.txt </li></ul></ul>
    11. 11. Funções para arquivos texto <ul><li>cat – concatenate </li><ul><li>cat a.txt b.txt > c.txt </li></ul><li>tac – concatenate and reverse </li><ul><li>tac < EOF abc xyz zzz EOF zzz xyz abc </li></ul></ul>
    12. 12. <ul><li>nl – number lines </li><ul><li>nl a.txt 1 texto x 2 texto y 3 texto z </li></ul><li>fold – limit width </li><ul><li>fold -w 30 -s a.txt </li></ul><li>head – first lines </li><ul><li>head -n 100 a.txt </li></ul><li>tail – last lines </li><ul><li>tail -n 30 a.txt
    13. 13. tail -f a.log </li></ul></ul>
    14. 14. <ul><li>split – split file into pieces </li><ul><li>split -l 20 a.txt arq. </li><ul><li>arq.aa, arq.ab, arq.ac …
    15. 15. -l lines, -c bytes </li></ul></ul><li>wc – word count </li><ul><li>wc -l a.txt </li><ul><li>-l -> lines
    16. 16. -c -> bytes
    17. 17. -m -> chars
    18. 18. -w -> words
    19. 19. -L -> longest line </li></ul></ul></ul>
    20. 20. <ul><li>sort – sort file </li><ul><li>sort a.txt b.txt </li><ul><li>-r, --reverse
    21. 21. -n, --numeric-sort
    22. 22. -h, --human-numeric-sort
    23. 23. -k <m[,n]>, --key </li></ul></ul><li>uniq – unique lines </li><ul><li>uniq a.txt </li><ul><li>-c, --count
    24. 24. -d, --repeated
    25. 25. -u, --unique </li></ul></ul></ul>
    26. 26. <ul><li>cut – remove sections from line </li><ul><li>echo 'a:b:c' | cut -d ':' -f 2 b </li><ul><li>-b, --bytes
    27. 27. -c, --character
    28. 28. -d, --delimiter
    29. 29. -f, --fields
    30. 30. --complement -> inverte a seleção
    31. 31. Obs.: campos na forma a,b,c-d </li></ul></ul></ul>
    32. 32. <ul><li>paste – merge files line-by-line </li><ul><li>paste -d '-' a.txt b.txt a.txt: c1 b.txt: a1 c2 a2 c3 a3 saída: c1-a1 c2-a2 c3-a3 </li><ul><li>-d, --delimiter </li></ul></ul><li>join – merge files line-by-line with field </li><ul><li>join a.txt b.txt </li></ul></ul>
    33. 33. <ul><li>tr – translate </li><ul><li>cat a.tx | tr a-z A-Z </li></ul><li>tee – write to multiple outputs </li><ul><li>cat a.txt | tee b.txt c.txt </li></ul><li>seq – print a sequence of numbers </li><ul><li>seq -s ' ' 0 5 20 0 5 10 15 20 </li><ul><li>-s, --separator </li></ul></ul></ul>
    34. 34. <ul><li>grep – regex search </li><ul><li>grep -E “[0-9]” a.txt </li><ul><li>-E, --extended-regexp
    35. 35. -i, --ignore-case
    36. 36. -v, --invert-match
    37. 37. -c, --count
    38. 38. -L, --files-without-match
    39. 39. -l, --files-with-match
    40. 40. -H, --without-filename
    41. 41. -h, --no-filename
    42. 42. -n, --line-number </li></ul></ul></ul>
    43. 43. <ul><li>sed – stream editor </li><ul><li>cat a.txt | sed -e '/^g/s/g/s/g'
    44. 44. -> troca todos os carteres 'g' por 's' nas linhas que começam com 'g' </li><ul><li>-e, --expression <script>
    45. 45. -r, --regex-extended
    46. 46. -n, --quite, --silent </li></ul><li>Script syntax: </li><ul><li>“ <pattern range> command”
    47. 47. pattern range: </li><ul><li>n,m -> line range
    48. 48. $ -> last line
    49. 49. /regex/,/regex/ -> regex </li></ul></ul></ul></ul>
    50. 50. <ul><li>sed – stream editor </li><ul><ul><li>command: </li><ul><li>d -> delete line
    51. 51. a -> append line
    52. 52. i -> insert line
    53. 53. p -> print line
    54. 54. = -> print line number
    55. 55. y/source/dest/ -> translate
    56. 56. s/regex/change/opts -> regex change
    57. 57. { } -> group commands </li></ul></ul></ul></ul>
    58. 58. <ul><li>sed – stream editor </li><ul><li>Ex: </li><ul><li>sed -e 's/day/night/' a.txt
    59. 59. sed -e '20,30 d' a.txt
    60. 60. sed -e '1,/^$/ d' a.txt
    61. 61. sed -n -e '/begin/,/end/ { s/#.*// /^$/ d p }' a.txt </li></ul></ul></ul>
    62. 62. E muito, muito mais.... man awk tar gzip pbzip2 cp mv ls rm uname id whoami touch more less which date dd df du sleep ln mkfifo nohup fmt
    63. 63. Obrigado

    ×