Mostrando postagens com marcador perl. Mostrar todas as postagens
Mostrando postagens com marcador perl. Mostrar todas as postagens

Artigo em inglês comparando o ack o grin e o grep

Neste link
http://incise.org/searching-for-a-good-grep.html

Conheça o ack um concorrente matador para o grep

http://betterthangrep.com/

Para instala-lo na sua pasta ~/bin (caso tenha) é moleza

curl http://betterthangrep.com/ack-standalone > ~/bin/ack && chmod 0755 !#:3

O parâmetro final pega o nome do executável como parâmetro do chmod

Top 10 reasons to use ack instead of grep.

  1. It's blazingly fast because it only searches the stuff you want searched.
  2. ack is pure Perl, so it runs on Windows just fine.
  3. The standalone version uses no non-standard modules, so you can put it in your ~/bin without fear.
  4. Searches recursively through directories by default, while ignoring .svn, CVS and other VCS directories.
    • Which would you rather type?
      $ grep pattern $(find . -type f | grep -v '\.svn')
      $ ack pattern
  5. ack ignores most of the crap you don't want to search
    • VCS directories
    • blib, the Perl build directory
    • backup files like foo~ and #foo#
    • binary files, core dumps, etc
  6. Ignoring .svn directories means that ack is faster than grep for searching through trees.
  7. Lets you specify file types to search, as in --perl or --nohtml.
    • Which would you rather type?
      $ grep pattern $(find . -name '*.pl' -or -name '*.pm' -or -name '*.pod' | grep -v .svn)
      $ ack --perl pattern
    Note that ack's --perl also checks the shebang lines of files without suffixes, which the find command will not.
  8. File-filtering capabilities usable without searching with ack -f. This lets you create lists of files of a given type.
    $ ack -f --perl > all-perl-files
  9. Color highlighting of search results.
  10. Uses real Perl regular expressions, not a GNU subset.
  11. Allows you to specify output using Perl's special variables
    • Example: ack '(Mr|Mr?s)\. (Smith|Jones)' --output='$&'
  12. Many command-line switches are the same as in GNU grep:
    -w does word-only searching
    -c shows counts per file of matches
    -l gives the filename instead of matching lines
    etc.
  13. Command name is 25% fewer characters to type! Save days of free-time! Heck, it's 50% shorter compared to grep -r.

Há uma ferramenta similar feita em python
http://pypi.python.org/pypi/grin

Leia mais sobre o grin aqui.

Macetes do Aurélio para renomear fotos atualizando a data

O Aurélio Marinho Jargas postou no seu blog uma dica legal sobre como corrigir datas em fotos, o link do artigo original é este: http://blog.aurelio.net/2010/05/15/datas-fotos-e-shell/

A dica faz uso da ferramenta exiftool feita em perl, para instalar faça:

sudo apt-get install libimage-exiftool-perl


Shell: data da foto, data do arquivo from Aurelio Jargas on Vimeo.

Problema: Você copiou algumas fotos para seu HD, mas a data do arquivo não bate com a data em que a foto foi tirada. Como arrumar isso? Veja o vídeo :)

Roteiro (espere o vídeo carregar):
00:32 - exiftool — extraí a data em que a foto foi tirada
01:10 - grep — pesquei a linha com a data
01:30 - cut — recortei a linha, descartando trechos inúteis
02:15 - touch — mudei a data do arquivo para a data atual
03:28 - tr — apaguei caracteres indesejados com a opção -d
04:07 - sed — inseri um ponto após um caractere com expressões regulares
05:02 - sed — usei um número no final do s/// para trocar a 12ª ocorrência
05:29 - OK, data e hora estão no formato certo
05:44 - touch — usei o -t para especificar uma data (aaaammddHHMM.SS)
06:23 - for — fiz um laço (loop) que percorre todos os arquivos
08:02 - $(…) — inseri a subshell dentro do loop
09:03 - Bug! Esqueci de usar a variável $foto dentro do loop
09:40 - SEMPRE USE ASPAS NAS VARIÁVEIS!
10:10 - Tática ninja: Use o echo antes de executar um comando complicado!
10:50 - Feito, datas arrumadas
10:59 - chmod — tirei a permissão de execução (Windows) dos arquivos

Nota: Esta não é a única nem a melhor maneira de resolver este problema. O que quero demonstrar é como "pensar em shell" para resolver seus problemas. Ir construindo os comandos, um a um, até chegar no seu objetivo.

Nota2: Se quiser aprofundar seus conhecimentos em shell, leia meu livro Shell Script Profissional http://www.shellscript.com.br

"Sobre a ferramenta exiftool: ExifTool is a Perl module with an included command-line application for reading and writing meta information in image, audio and video files. It recognizes EXIF, GPS, IPTC, XMP, JFIF, GeoTIFF, ICC Profile, Photoshop IRB, FlashPix, AFCP and ID3 meta information as well as the maker notes of many digital cameras including Canon, Casio, FujiFilm, JVC/Victor, Kodak, Leaf, Minolta/Konica-Minolta, Nikon, Olympus/Epson, Panasonic/Leica, Pentax/Asahi, Ricoh, Sanyo and Sigma/Foveon."
fonte: http://linuxappfinder.com/package/libimage-exiftool-perl
Não deixe de dar uma olhada no site: http://linuxappfinder.com/ para pesquisar boas aplicações linux.

linux-cookbook

Grupos do Google
Participe do grupo linux-cookbook
E-mail:
Visitar este grupo