The following alias for finding a file works in tcsh but not in bash.

alias ff "find . -name '*\!{*}*' -ls"

When I put the above line in .bashrc and then source it I get :

bash-3.2$ source .bashrc
bash: alias: ff: not found
bash: alias: find . -name '*\!{*}*' -ls: not found

Now if I define the alias but putting an equals sign just after the alias name the above error goes away but it doesn't work as expected.

 alias ff="find . -name '*\!{*}*' -ls" 

Now if I source the file the previous error goes away but the find command doesn't work as expected.

 bash-3.2$ source .bashrc
 bash-3.2$ ff somefile
 find: paths must precede expression
 Usage: find [-H] [-L] [-P] [path...] [expression]
  • What is the tcsh alias supposed to do? – choroba Sep 1 '14 at 10:38
  • @choroba the alias will give a long listing of any file or directory names that contain the argument when a file or directory name is given as an argument. – Geek Sep 1 '14 at 10:40

Aliases in bash can't process arguments. If you need to process an argument, use a function instead:

ff () { find . -name "*$1*" -ls ; }
  • What does *$1* expand to? – Geek Sep 1 '14 at 10:48
  • first argument to ff command between ** – pqnet Sep 1 '14 at 12:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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