Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

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 am trying to define alias for a group of commands counting and displaying the number of all files in account’s space with the names starting with g, t, and w. I got the result with the following command.

   find $HOME -name '[gtw]*' | wc -l

But when I try to give the command, alias I got error

  alias noAgtw='find $HOME -name '[gtw]*'| wc -l '

The error reads like this


find: paths must precede expression: testing

Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec]  

[path...] [expression] 


Can anyone help me please?

share|improve this question
up vote 1 down vote accepted


alias noAgtw="find $HOME -name '[gtw]*' | wc -l"


alias noAgtw='find '"$HOME"' -name "[gtw]*" | wc -l'

Looking at this new definition, I think you can figure that you misused simple quotes...

Also, never use a variable (as in your case $HOME is) inside single quotes. See why here:

share|improve this answer
Will you please answer my next question regarding alias? – Narwen Nov 14 '13 at 9:11
I just posted it!! – Narwen Nov 14 '13 at 9:35

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.