[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bash argument expanded inside alias

On Tue, 13 Mar 2012 23:17:41 -0300, rcb wrote:

>> From: Camaleón <noelamac@gmail.com>
>> Date: Tue, 13 Mar 2012 18:06:11 +0000 (UTC)
>> > does not work to do what your intuition imagine what I want it to do?
>> It's not the alias but the command itself. ***
>> alias muda='find . -name "*" -mtime $1' ***
>> And pass the negative value "-n" as argument (e.g., "muda -2")
> Dear Camaleón,
> That is definitely the most elegant solution. Thanks!
> I was wondering, why the "-" cannot be there? Can we "escape" it?

You're trying to assing a negative value to the argument, regardless the 
argument's value. My guess is that you may need to make the conversion 
first -using sed?- and then use the resulting output as argument.

> I mean, what if it was a file name, we can always concatenate, lets say
> "file-$1-$2.pdf", can't we?

You mean you want to find for "file1.pdf", "file2.pdf", "filen.pdf"...?

Mmm, maybe you can adapt your command line for that, for instance:

alias muda='find . -name $1 -or -name $2 -mtime $3'



Reply to: