using echo 'text' > file (to add to last line of several documents)

Eric Shubert ejs at shubes.net
Wed Oct 27 14:08:58 MST 2010


Thanks for clearing that up for me hans (and Dale).
I'll still steer clear of aliases though. When I find myself doing 
something repetitively, I'll write a script. ;)

On 10/27/2010 02:04 PM, der.hans wrote:
> moin moin Eric,
>
> An alias will only get expanded in place of a command.
>
> $ .. # .. gets replaced by Matt's alias ( if you have it )
> $ cd .. # is the string ˙..'
>
> aliases are not expanded in every location, just the first place.
>
>  From the bash man page: "Aliases allow a string to be substituted for a
> word when it is used as the first word of a simple command."
>
> Not sure what happens if you use sudo to run an alias.
>
> If the alias is available ( since you're changing users that's not
> absolutely certain ), I would think it gets expanded when sudo tries to
> run the command.
>
> sudo ..
>
> I think that would switch to the root user, then try to run the ..
> command. If Matt's alias is available, then it would be run ( rather
> pointlessly in this case ). I believe sudo would be handed .. as the
> command rather than Matt's alias expansion.
>
> command completion functions might change that such that "sudo ..<tab>"
> would auto-expand the alias to "sudo cd .." on the command line.
>
> ciao,
>
> der.hans
>
> Am 27. Oct, 2010 schwätzte Eric Shubert so:
>
>> On 10/27/2010 01:02 PM, Matt Graham wrote:
>>> From: Eric Shubert<ejs at shubes.net>
>>>> On 10/27/2010 12:30 PM, Matt Graham wrote:
>>>>> alias ..='cd ..'
>>>>> alias ...='cd ../..'
>>>>>
>>>>> ....and I don't believe you can write a script named ".." without
>>>>> a lot of fooling around....
>>>> What happens though when you try to use the real command? Does it
>>>> result in: $ cd cd ..
>>>
>>> "man bash" , the ALIASES section:
>>>
>>> The first word of the replacement text is tested for aliases, but a
>>> word that
>>> is identical to an alias being expanded is not expanded a second
>>> time. This
>>> means that one may alias ls to ls -F, for instance, and bash does not
>>> try to
>>> recursively expand the replacement text.
>>>
>>> No idea what non-bash things do.
>>>
>>
>> That doesn't appear to me to say you won't get
>> $ cd cd ..
>> if you type
>> $ cd ..
>> when your alias is defined.
>>
>>
>


-- 
-Eric 'shubes'



More information about the PLUG-discuss mailing list