Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I don't know how to ask this, but let me explain.

I have a text file (named bla) in my ~/user/Dropbox folder. I would like to grep on it from any folder in terminal.

For example, I'd like just type grep 'foo' bla instead of going to ~/user/Dropbox to look for.

I believe that some symbolic link could help. Any idea?

share|improve this question
    
@sputnick, sorry but I have no idea about what you're saying. –  Sigur Mar 26 '13 at 23:03
add comment

1 Answer 1

up vote 2 down vote accepted

Basically, you can give the full path to grep:

grep foo ~/user/Dropbox/bla

Or you could add a function on your ~/.bashrc file, so you won't need to type the full path:

dgrep(){
    grep "$1" "~/user/Dropbox/$2"
}

Running the function (after you open a new shell or run . .bashrc):

dgrep foo bla

EDIT: dgrep is a tool contained in debian-goodies that searches all files in specified packages for a regex. It should be safe to use this name if you don't use Debian or are not an advanced user. Otherwise, change dgrep to something else.

share|improve this answer
1  
+1. Thanks so much. Since I'll grep on the same file everytime, I defined a function (called busca, which means find in my language) only with one argument so I just call busca foo. –  Sigur Mar 26 '13 at 23:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.