Important! This is an automatic machine translated page. If you can read english, you should Click Here to read the original English version of the article.

Find files containing search terms on Ubuntu Tìm tập tin có chứa các điều kiện tìm kiếm trên Ubuntu

To find files containing keywords, linux has a powerful command called grep, which you can use to find the lines inside any file or a list of files. Để tìm tập tin có chứa từ khóa, Linux có một lệnh gọi là grep mạnh mẽ, mà bạn có thể sử dụng để tìm các đường bên trong bất kỳ tập tin hoặc một danh sách các tập tin. I use this very often to find a function declaration in a set of php files that I'm unfamiliar with. Tôi sử dụng này rất thường xuyên để tìm một tờ khai chức năng trong một bộ các tập tin php rằng tôi không quen với.

Let's say we are looking for the definition of a function called wp_content_filterize, and we don't know where to start. Hãy nói rằng chúng tôi đang tìm kiếm định nghĩa của một hàm được gọi là wp_content_filterize, và chúng tôi không biết bắt đầu từ đâu. Let's try using grep… Hãy thử sử dụng grep ...

grep -i -n 'function wp_content_filterize' * grep-i-n 'chức năng wp_content_filterize' *

We should see the output right on the console Chúng ta sẽ thấy quyền đầu ra trên giao diện điều khiển

functions.php:18:function wp_content_filterize($thefilter) { functions.php: 18: chức năng wp_content_filterize ($ thefilter) (

Now we know that the function definition is found in the file functions.php, on line 18. Bây giờ chúng ta biết rằng các định nghĩa chức năng được tìm thấy trong các tập tin functions.php, trên đường 18.

This article was originally written on 09/11/06 Tagged with: Bài viết này ban đầu được viết ngày 09/11/06 Tagged với: Ubuntu Ubuntu

Daily Email Updates Email cập nhật hàng ngày

You can get our how-to articles in your inbox each day for free. Bạn có thể làm thế nào chúng tôi vào các bài viết trong hộp thư của bạn mỗi ngày miễn phí. Just enter your name and email below: Chỉ cần nhập tên và email của bạn dưới đây:


Name: Tên:
Email: Email:

Comments (7) Bình luận (7)

  1. Ajo Paul Ajo Paul

    find . tìm. -name “filenames” -exec grep -i -H -n 'texttofind' {} \; -name "tên tập tin"-exec grep-i-H-n 'texttofind' () \;

    To search within sub-directories Để tìm kiếm trong tiểu thư mục

  2. Mark Olech Mark Olech

    I use windows 2000 and xp. Tôi sử dụng các cửa sổ 2000 và xp. I need a way to search withing a list of text files for a specific number. Tôi cần một cách để tìm kiếm trong một danh sách các tập tin văn bản cho một số cụ thể. I want to then take the search results and output the lines of text containing this number to a text file, or possibly an html document that will then open up. Tôi muốn sau đó lấy kết quả tìm kiếm và đầu ra các dòng văn bản có chứa các con số này vào một tập tin văn bản, hoặc có thể là một tài liệu html mà sau đó sẽ mở ra. Basically, I need to output the results into some form of data that I can easily read. Về cơ bản, tôi cần phải ra các kết quả vào một số dạng dữ liệu mà tôi có thể dễ dàng đọc. Are there any free programs that I can use to do this or do you have any ideas? Có bất kỳ chương trình miễn phí mà tôi có thể sử dụng để làm điều này hay không bạn có bất kỳ ý tưởng?

  3. imasdeweb.com imasdeweb.com

    Now i'm using UBUNTU-LINUX, but before -when i worked in winXP- one of my preferred applications were Agent Ransack (freeware). Bây giờ tôi đang sử dụng Ubuntu-LINUX, nhưng trước, khi tôi làm việc trong WinXP-một trong những ứng dụng ưa thích của tôi đã được Đại lý Ransack (freeware). Here is its offcial webpage: Đây là trang web offcial của nó:

    http://www.mythicsoft.com/agentransack/ http://www.mythicsoft.com/agentransack/

    This application is the only i would like to have in UBUNTU. Ứng dụng này là tôi chỉ muốn có trong Ubuntu. Once it is installed, you simply do click with secondary button mouse over a directory and click on “Search with Agent Ransack”, and… fantastic: it find very rapidly all files (indicating the exact line) wich contains the string you search!! Một khi nó được cài đặt, bạn chỉ cần làm với kích chuột vào nút thứ hai trong một thư mục và bấm vào "Tìm kiếm với chất da Ransack", và ... tuyệt vời: nó tìm rất nhanh tất cả các file (chỉ chính xác dòng), chứa chuỗi bạn tìm kiếm!!

    I would like to know if exists some like this for UBUNTU Tôi muốn biết nếu một số tồn tại như thế này cho Ubuntu ;) )) ))

    SERGIO R. Sergio R.

  4. imasdeweb.com imasdeweb.com

    Eyyyy… i found it. Eyyyy ... tôi thấy nó.
    Great application for developers (indeed for UBUNTU): Tuyệt vời cho các nhà phát triển ứng dụng (thực sự cho Ubuntu):

    http://regexxer.sourceforge.net http://regexxer.sourceforge.net

    ;)

    SERGIO Sergio

  5. The Geek The Geek

    @Sergio: @ Sergio:

    That's a really awesome find! Đó là một awesome thực sự tìm thấy! I've always wanted an app like that… will be featuring an article about it. Tôi đã luôn luôn muốn một ứng dụng như rằng ... sẽ được tính năng một bài viết về nó.

  6. speed tốc độ

    how do I find some text only in some specific files in a directory, lets say I want grep to look only in .c files only ? làm thế nào để tìm thấy một số văn bản chỉ trong một số tác phẩm cụ thể trong một thư mục, cho phép nói rằng tôi muốn grep để tìm duy nhất trong. c tập tin chỉ?

  7. Anderson Anderson

    @Ajo : @ Ajo:
    In fact you can use -R option on grep to do it recursively (maybe it's a recent thing, this post is back to 2007, I know) Trong thực tế bạn có thể sử dụng tùy chọn-R trên grep để làm điều đó đệ quy (có thể nó là một điều gần đây, đăng bài này là trở lại với năm 2007, tôi biết)

    grep -R 'pattern' * grep-R 'mẫu' *


Our Friends Bạn bè của chúng tôi
Getting Started Bắt đầu


About How-To Geek Giới How-To Geek
What Is That Process? Quá trình đó là gì?
svchost.exe svchost.exe
jusched.exe jusched.exe
dwm.exe dwm.exe
ctfmon.exe ctfmon.exe
wmpnetwk.exe wmpnetwk.exe
wmpnscfg.exe wmpnscfg.exe
rundll32.exe rundll32.exe
wfcrun32.exe wfcrun32.exe
Ipoint.exe Ipoint.exe
Itype.exe Itype.exe
Wfica32.exe Wfica32.exe
Mobsync.exe Mobsync.exe
conhost.exe conhost.exe
Dpupdchk.exe Dpupdchk.exe Adobe_Updater.exe Adobe_Updater.exe

Copyright © 2006-2009 HowToGeek.com. Bản quyền © 2006-2009 HowToGeek.com. All Rights Reserved. Tất cả các quyền.