前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Quickly Find Content in Files

Quickly Find Content in Files

作者头像
技术小黑屋
发布2018-09-04 16:40:40
3800
发布2018-09-04 16:40:40
举报
文章被收录于专栏:技术小黑屋技术小黑屋

Although Eclipse does provide a lot of facilities for Finding content is Workspace files, it maybe less efficient for find something such as a certain package or class usage. Actually we could do it more efficient and geeky.

Now we use the classic Unix command grep.

1 2 3 4 5 6

#Grammar grep -E "word_to_search" folder_to_search -R --color=always -n #Demo grep -E "android.os.Looper" ./ -R --color=always -n .//src/com/mining/app/zxing/decoding/DecodeHandler.java:23:import android.os.Looper; .//src/com/mining/app/zxing/decoding/DecodeThread.java:24:import android.os.Looper;

Let’s take a look at the command arguments explanation.

-E, —extended-regexp Interpret pattern as an extended regular expression (i.e. force grep to behave as egrep). -R, -r, —recursive Recursively search subdirectories listed. —colour=[when, —color=[when]] Mark up the matching text with the expression stored in GREP_COLOR environment variable. The possible values of when can be never, always or auto. -n, —line-number Each output line is preceded by its relative line number in the file, starting at line 1. The line number counter is reset for each file processed.

Is this trick awesome? Save it as a bash script named quickfind.sh.

1 2

#!/bin/bash grep -E $1 . -R --color=always -n

Then let it executable and just run it.

1 2

chmod a+x quickfind.sh quickfind.sh "android.os.Looper"

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档