Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I always used the following command to filter out my contacts email addresses from a directory in Kali Linux:

grep -rIhEo "\b[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+\b" >> 1A

I tried it in Ubuntu now and its not working. There is no error message, just its doing something but without result and end. Why?

I tried with Ubuntu 12.04 and Xubuntu 12.04.


share|improve this question
I believe it's because Ubuntu's default shell is dash, whereas Kali Linux uses chsh as default shell. Source – Aserre Apr 8 '14 at 13:57
I changed the shell now to /bin/bash. The problem remains. – DataDriven Apr 8 '14 at 14:06
What's the input you're testing this with? – Oli Apr 8 '14 at 14:16
@Ploutox Ubuntu ships with bash as default, I'm pretty sure. Also, I don't think it matters anyway, since grep isn't a bash builtin, but a separate binary in its own right. – Sparhawk Apr 8 '14 at 14:20
Perhaps it has something to do with your locale settings? See if this makes a difference if you use [[:alnum:]._-] instead of [a-zA-Z0-9._-] – Scrutinizer Apr 8 '14 at 14:50
up vote 2 down vote accepted

Specify files as input to the grep command:

grep -rIhEo "\b[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+\b" file(s) >> 1A

Or specify files with a wildcard or use the current directory.

grep -rIhEo "\b[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+\b" . >> 1A 

GREP(1)                                                                GREP(1)

       grep, egrep, fgrep - print lines matching a pattern

       grep [OPTIONS] PATTERN [FILE...]
       grep [OPTIONS] [-e PATTERN | -f FILE] [FILE...]
share|improve this answer
You got it. Thanks so much for your persistent help! So in Ubuntu standard shell you need to specify the directory, in Kali Linux standard shell it takes the current directory if no is specified. – DataDriven Apr 8 '14 at 19:37
@DataDriven . You are welcome, glad you found it.. – Scrutinizer Apr 8 '14 at 19:52
@DataDriven That's really interesting though. I wonder if Kali Linux would attempt to use . if there is an error? That seems quite strange. (I presume this difference is from the shell and not grep.) – Sparhawk Apr 8 '14 at 23:06

Your Answer


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.