SORU
27 Temmuz 2011, ÇARŞAMBA


Nasıl bulma komutu ile düzenli ifade kullanmak?

Bazı resimler oluşturulan uuid1 dize ile adlandırılmış. Örneğin 81397018-b84a-11e0-9d2a-001b77dc0bed.jpg. Tüm bu görüntüleri kullanarak öğrenmek istiyorum "" komut:

find . -regex "[a-f0-9\-]\{36\}\.jpg".

Ama çalışmıyor. Normal ifade ile yanlış bir şey? Biri bana bu konuda yardım edebilir mi?

CEVAP
27 Temmuz 2011, ÇARŞAMBA


find . -regextype sed -regex ".*/[a-f0-9\-]\{36\}\.jpg"

find tüm yol ile eşleşir çünkü başlangıçta .*/ belirtmeniz gerektiğini unutmayın.

Örnek:

susam@nifty:~/so$ find . -name "*.jpg"
./foo-111.jpg
./test/81397018-b84a-11e0-9d2a-001b77dc0bed.jpg
./81397018-b84a-11e0-9d2a-001b77dc0bed.jpg
susam@nifty:~/so$ 
susam@nifty:~/so$ find . -regextype sed -regex ".*/[a-f0-9\-]\{36\}\.jpg"
./test/81397018-b84a-11e0-9d2a-001b77dc0bed.jpg
./81397018-b84a-11e0-9d2a-001b77dc0bed.jpg

Bulmak benim sürümü:

$ find --version
find (GNU findutils) 4.4.2
Copyright (C) 2007 Free Software Foundation, Inc.
License GPLv3 : GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Eric B. Decker, James Youngman, and Kevin Dalley.
Built using GNU gnulib version e5573b1bad88bfabcda181b9e0125fb0c52b7d3b
Features enabled: D_TYPE O_NOFOLLOW(enabled) LEAF_OPTIMISATION FTS() CBO(level=0) 
susam@nifty:~/so$ 
susam@nifty:~/so$ find . -regextype foo -regex ".*/[a-f0-9\-]\{36\}\.jpg"
find: Unknown regular expression type `foo'; valid types are `findutils-default', `awk', `egrep', `ed', `emacs', `gnu-awk', `grep', `posix-awk', `posix-basic', `posix-egrep', `posix-extended', `posix-minimal-basic', `sed'.

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • NLthomas21

    NLthomas21

    20 Mayıs 2008
  • ThePhestor

    ThePhestor

    22 Mart 2011
  • TheRightTire

    TheRightTire

    14 EKİM 2009