Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

noAgtw

find: paths must precede expression: testing

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

[path...] [expression] 

0 

Can anyone help me please?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Use:

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

or:

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

 
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.