FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 03-13-2012, 01:34 PM
rcb
 
Default Bash argument expanded inside alias

Dear Debian users,
Anyone knows why this command:
:~$ alias muda='find . -name "*" -mtime -$1'
and all this variations I tried:

:~$ alias muda='find . -name "*" -mmin -`echo $1`'
:~$ alias muda='find . -name "*" -mmin `echo -$1`'
:~$ alias muda='find . -name "*" -mmin $(echo -$1)'

:~$ alias muda='find . -name "*" -mmin -$@'
:~$ alias muda='find . -name "*" -mmin -`echo "$1"`'
:~$ alias muda='find . -name "*" -mmin `echo "-$1"`'
:~$ alias muda='find . -name "*" -mmin $(echo "-$1")'
does not work to do what your intuition imagine what I want it to do?
Thanks, non-computer minds, for any help.

Beco.
 
Old 03-13-2012, 02:49 PM
Clive Standbridge
 
Default Bash argument expanded inside alias

> Dear Debian users,
>
> Anyone knows why this command:
>
> :~$ alias muda='find . -name "*" -mtime -$1'
>
> and all this variations I tried:
[...]
> does not work to do what your intuition imagine what I want it to do?

Hi Beco,

It doesn't work because aliases don't take arguments.
You can use a shell function instead. For example,

muda()
{
find . -name "*" -mtime -$1
}


--
Cheers,
Clive


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20120313154947.GA15377@rimmer.localdomain">http://lists.debian.org/20120313154947.GA15377@rimmer.localdomain


Tue Mar 13 18:30:01 2012
Return-path: <arch-general-bounces@archlinux.org>
Envelope-to: tom@linux-archive.org
Delivery-date: Tue, 13 Mar 2012 18:09:13 +0200
Received: from gerolde.archlinux.org ([66.211.214.132]:58568)
by s2.java-tips.org with esmtp (Exim 4.69)
(envelope-from <arch-general-bounces@archlinux.org>)
id 1S7UHh-0005vW-Nw
for tom@linux-archive.org; Tue, 13 Mar 2012 18:09:13 +0200
Received: from gudrun.archlinux.org (gudrun.archlinux.org [66.211.214.131])
by gerolde.archlinux.org (Postfix) with ESMTP id 73A5290079;
Tue, 13 Mar 2012 12:09:03 -0400 (EDT)
Received: from gerolde.archlinux.org (gerolde.archlinux.org [66.211.214.132])
by gudrun.archlinux.org (Postfix) with ESMTP id 0258D7004C
for <arch-general@archlinux.org>; Tue, 13 Mar 2012 12:09:00 -0400 (EDT)
Received-SPF: pass (gmail.com ... _spf.google.com: 209.85.214.44 is authorized
to use 'techlivezheng@gmail.com' in 'mfrom' identity (mechanism
'ip4:209.85.128.0/17' matched)) receiver=gerolde.archlinux.org;
identity=mailfrom; envelope-from="techlivezheng@gmail.com";
helo=mail-bk0-f44.google.com; client-ip=209.85.214.44
Received: from mail-bk0-f44.google.com (mail-bk0-f44.google.com
[209.85.214.44])
by gerolde.archlinux.org (Postfix) with ESMTPS id 929D790076
for <arch-general@archlinux.org>; Tue, 13 Mar 2012 12:09:00 -0400 (EDT)
Received: by bkuw5 with SMTP id w5so553636bku.3
for <arch-general@archlinux.org>; Tue, 13 Mar 2012 09:09:11 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
h=mime-version:in-reply-to:references:from:date:message-id:subject:to
:content-type:content-transfer-encoding;
bh=2fZl9tPH0mh2Qpei3Sz7p5tHyvJICgnkzTzHHuZUPXg=;
b=Y1QuppiI6u8wjb8L2DoGSJK3l4Bk3WpTKFeTIkIp0RRbtsOq 6QdePWGz7pFGl8DZXd
ugYC9DInaqc2hhbmQC4d5iqTIladTDZk1p/XmfAxAC6Btk/ECyE96TY9KU46TxHjYbMl
9chMxHWuy2L0PuNsedw65bxRorzNJX9NPrsoXtBXn2wNkEdeEs CZCr1QjcLODdbtxQHJ
JrusXnzzSgknZYea1AYvqP4IZJ8FBoSEWf5/+doGhqM654kGnT/XeO4zveLh/SGBSun5
y/35Ddx5D3tDgQETDCwl8aPT2e13dhsbwwjfXc2CLO+/nFmWwDPcVGLFbshpvmYOmBG0
6nLw==
Received: by 10.204.145.81 with SMTP id c17mr6672707bkv.39.1331654951405; Tue,
13 Mar 2012 09:09:11 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.204.153.195 with HTTP; Tue, 13 Mar 2012 09:08:31 -0700 (PDT)
In-Reply-To: <4F5F12B9.60005@gmx.de>
References: <CAPYzjrS7G7nHouEKfYXP8hcZWJiSWPkhsm4QPw7YQkmeMA95 Cg@mail.gmail.com>
<4F5F12B9.60005@gmx.de>
From: =?UTF-8?B?6YOR5paH6L6JKFRlY2hsaXZlIFpoZW5nKQ==?=
<techlivezheng@gmail.com>
Date: Wed, 14 Mar 2012 00:08:31 +0800
Message-ID: <CAPYzjrTRLSzmSuOes-4J1fP2JrXjSAJENLaS7ASF69Lp_-6XUg@mail.gmail.com>
To: General Discussion about Arch Linux <arch-general@archlinux.org>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Subject: Re: [arch-general] How can I change thunderbird profile dir form
.thunderbird to .mozilla/thunderbird?
X-BeenThere: arch-general@archlinux.org
X-Mailman-Version: 2.1.14
Precedence: list
Reply-To: General Discussion about Arch Linux <arch-general@archlinux.org>
List-Id: General Discussion about Arch Linux <arch-general.archlinux.org>
List-Unsubscribe: <http://mailman.archlinux.org/mailman/options/arch-general>,
<mailto:arch-general-request@archlinux.org?subject=unsubscribe>
List-Archive: <http://mailman.archlinux.org/pipermail/arch-general>
List-Post: <mailto:arch-general@archlinux.org>
List-Help: <mailto:arch-general-request@archlinux.org?subject=help>
List-Subscribe: <http://mailman.archlinux.org/mailman/listinfo/arch-general>,
<mailto:arch-general-request@archlinux.org?subject=subscribe>
Errors-To: arch-general-bounces@archlinux.org
Sender: arch-general-bounces@archlinux.org

2012/3/13 G. Schlisio <g.schlisio@gmx.de>:
> Am 11.03.2012 03:10, schrieb =E9=83=91=E6=96=87=E8=BE=89(Techlive Zheng):
>
>> Is there any compile flag or something I could alter? I think that
>> would be easy to do. I just want to clean my home folder, backup
>> firefox and thunderbird data. I only want to backup a .mozilla
>> directory and not .mozilla and .thunderbird them two.
>>
>> So,anyone knows?
>>
>> Besides, I don't want to symlink .mozilla/thunderbird to .thunderbird,
>> that won't solve the problem, I am willing to recomplie the whole
>> thunderbird if necessary.
>>
>> Regards,
>> Techlive Zheng
>>
> its just too easy, you can configure it in profile settings. in server
> settings you can choose the local folder. thats what you need?

Thanks to all of you, I have solved this problem.

As I mentioned before, I am not mean to change the profile location,
eg ~/.thunderbird/*.defulat to elsewhere, I want to change
~/.thunderbird itsself to ~/.mozilla/thunderbird which profile manager
can not help.

Finally, thanks to lee@mozillazine, I found how to change that by
altering the source code.

--- mail/app/application.ini 2012-03-13 23:58:49.204534467 +0800 10.0.2
+++ mail/app/application.ini 2012-03-13 23:26:47.991609239 +0800
@@ -37,6 +37,7 @@

#filter substitution
[App]
+Vendor=3DMozilla
Name=3DThunderbird
Version=3D@APP_VERSION@
BuildID=3D@GRE_BUILDID@

Here are the links of upstream bugreports:

<https://bugzilla.mozilla.org/show_bug.cgi?id=3D247973>
<https://bugzilla.mozilla.org/show_bug.cgi?id=3D424641>
 
Old 03-13-2012, 03:07 PM
Clive Standbridge
 
Default Bash argument expanded inside alias

On Tue 13 Mar 2012 15:49:52 +0000(+0000), Clive Standbridge wrote:
> > Dear Debian users,
> >
> > Anyone knows why this command:
> >
> > :~$ alias muda='find . -name "*" -mtime -$1'
> >
> > and all this variations I tried:
> [...]
> > does not work to do what your intuition imagine what I want it to do?
>
> Hi Beco,
>
> It doesn't work because aliases don't take arguments.

Oh I think I misunderstood the question.
On second thoughts, I think you probably meant to use an alias inside
a shell script, and to use the script's argument in the alias. In that
case, the problem would be shell parameters are not expanded inside
single quotes. You would need to use double quotes, for example

alias muda="find . -name '*' -mtime -$1"


--
Cheers,
Clive


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20120313160739.GA2602@rimmer.localdomain">http://lists.debian.org/20120313160739.GA2602@rimmer.localdomain
 
Old 03-13-2012, 03:13 PM
Tom H
 
Default Bash argument expanded inside alias

On Tue, Mar 13, 2012 at 10:34 AM, rcb <rcb@beco.cc> wrote:
>
> Anyone knows why this command:
>
> :~$ alias muda='find . -name "*" -mtime -$1'
>
> and all this variations I tried:
>
> :~$ alias muda='find . -name "*" -mmin -`echo $1`'
> :~$ alias muda='find . -name "*" -mmin `echo -$1`'
> :~$ alias muda='find . -name "*" -mmin $(echo -$1)'
> :~$ alias muda='find . -name "*" -mmin -$@'
> :~$ alias muda='find . -name "*" -mmin -`echo "$1"`'
> :~$ alias muda='find . -name "*" -mmin `echo "-$1"`'
> :~$ alias muda='find . -name "*" -mmin $(echo "-$1")'
>
> does not work to do what your intuition imagine what I want it to do?

mudafct() { find ... ; }
alias muda='mudafct'


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: CAOdo=SxEGuE-b-pn8Cu3v2Qd-FP3u7bn7--B1atoU3cxsKpZAw@mail.gmail.com">http://lists.debian.org/CAOdo=SxEGuE-b-pn8Cu3v2Qd-FP3u7bn7--B1atoU3cxsKpZAw@mail.gmail.com
 
Old 03-13-2012, 03:17 PM
Tom H
 
Default Bash argument expanded inside alias

On Tue, Mar 13, 2012 at 11:49 AM, Clive Standbridge
<list-user@tgstandbridges.plus.com> wrote:
>>
>> Anyone knows why this command:
>>
>> :~$ alias muda='find . -name "*" -mtime -$1'
>>
>> and all this variations I tried:
> [...]
>> does not work to do what your intuition imagine what I want it to do?
>
> Hi Beco,
>
> It doesn't work because aliases don't take arguments.
> You can use a shell function instead. For example,
>
> muda()
> {
> * find . -name "*" -mtime -$1
> }

My added alias was silly...


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: CAOdo=SzrK6mYBrMGfs-f8g951Y1hsZeqg0OuJzHO8N+u4dainw@mail.gmail.com">ht tp://lists.debian.org/CAOdo=SzrK6mYBrMGfs-f8g951Y1hsZeqg0OuJzHO8N+u4dainw@mail.gmail.com
 
Old 03-13-2012, 04:47 PM
rcb
 
Default Bash argument expanded inside alias

Dear Clive, dear Tom,

Thanks for your time!

The solution:

mudafct() { find . -name "*" -mtime -$1; }
alias muda='mudafct'

seems to works inside .bashrc file! (Just 'seems' because I did not
reboot, just typed in a terminal and it worked great!)

Thanks both,

Beco.



To:*debian-user@lists.debian.org
Subject: Re: Bash argument expanded inside alias
From: Clive Standbridge <list-user@tgstandbridges.plus.com>
Date: Tue, 13 Mar 2012 15:49:52 +0000


> does not work to do what your intuition imagine what I want it to do?

Hi Beco,

It doesn't work because aliases don't take arguments.
You can use a shell function instead. For example,

muda()
{
find . -name "*" -mtime -$1
}


--
Cheers,
Clive


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: CALuYw2yfe8axDTNfx3ydhMEP1aQ7_C0sndwBA+CLVm_Tck0fe Q@mail.gmail.com">http://lists.debian.org/CALuYw2yfe8axDTNfx3ydhMEP1aQ7_C0sndwBA+CLVm_Tck0fe Q@mail.gmail.com
 
Old 03-13-2012, 05:06 PM
Camaleón
 
Default Bash argument expanded inside alias

On Tue, 13 Mar 2012 11:34:12 -0300, rcb wrote:

(no html, please)

> Dear Debian users,
>
> Anyone knows why this command:
>
> :~$ alias muda='find . -name "*" -mtime -$1'

(...)

> 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")

Greetings,

--
Camaleón


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: jjo2aj$7rc$3@dough.gmane.org">http://lists.debian.org/jjo2aj$7rc$3@dough.gmane.org
 
Old 03-14-2012, 01:17 AM
rcb
 
Default Bash argument expanded inside alias

> 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")
> Greetings,
> --
> Camaleón


Dear Camaleón,

That is definitely the most elegant solution. Thanks!

I was wondering, why the "-" cannot be there? Can we "escape" it?

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

Cheers,
Beco.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: CALuYw2yyqaagEJKj+szQ6BpZsU=0=piFfLENAC09+TPexXZDu g@mail.gmail.com">http://lists.debian.org/CALuYw2yyqaagEJKj+szQ6BpZsU=0=piFfLENAC09+TPexXZDu g@mail.gmail.com
 
Old 03-14-2012, 11:47 AM
Chris Davies
 
Default Bash argument expanded inside alias

rcb <rcb@beco.cc> wrote:
> mudafct() { find . -name "*" -mtime -$1; }

Is there any reason why you're using a { -name "*" } part? A quick test
suggests that you might as well discard it:

mudafct() { find . -mtime -"$1"; }

Chris


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: njg639xh3g.ln2@news.roaima.co.uk">http://lists.debian.org/njg639xh3g.ln2@news.roaima.co.uk
 
Old 03-14-2012, 02:16 PM
Camaleón
 
Default 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'
***

Greetings,

--
Camaleón


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: jjqco0$3nj$4@dough.gmane.org">http://lists.debian.org/jjqco0$3nj$4@dough.gmane.org
 

Thread Tools




All times are GMT. The time now is 07:13 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2007 - 2008, www.linux-archive.org