PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > tcsh Aliases to bash Aliases?
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

tcsh Aliases to bash Aliases?

Réponse
 
LinkBack Outils de la discussion
Vieux 27/07/2007, 23h59   #1
qquito
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut tcsh Aliases to bash Aliases?

Dear Everybody:

Aliases with arguments do not work under the shell Bash, but I have
used a number of such aliases under tcsh, and the following is a few
examples:

(1) alias agrep 'grep \!:1 /myhome/.addresses' (1
argument)
(2) alias fd 'find /myhome/work/xyz -name \!:1 -print' (1
argument)
(3) alias t2ps 'enscript -j -U 2 -C -G --word-wrap -o \!:2 \!:1' (2
arguments)

How would you convert the above 3 examples into scripts that can be
used under bash?

Additionally, can you put the scripts in one single file with each one
occupying one line?

Thanks for reading and replying!

--Roland

  Réponse avec citation
Vieux 28/07/2007, 00h25   #2
Sam
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: tcsh Aliases to bash Aliases?

qquito writes:

> Dear Everybody:
>
> Aliases with arguments do not work under the shell Bash, but I have
> used a number of such aliases under tcsh, and the following is a few
> examples:
>
> (1) alias agrep 'grep \!:1 /myhome/.addresses' (1
> argument)
> (2) alias fd 'find /myhome/work/xyz -name \!:1 -print' (1
> argument)
> (3) alias t2ps 'enscript -j -U 2 -C -G --word-wrap -o \!:2 \!:1' (2
> arguments)
>
> How would you convert the above 3 examples into scripts that can be
> used under bash?


The bash equivalent would be functions, for example:

fd() {
find ~ -name "$1" -print
}

then:

fd filename

The bash equivalent of the other two of your aliases is left for you as
a homework excersize.

> Additionally, can you put the scripts in one single file with each one
> occupying one line?


Yes, you can put as many of them as you want, in a file. Bash functions are
not limited to one line.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQBGqn7kx9p3GYHlUOIRAqqUAJ9Xce9fPNbmOXRtEBSsxC 05BLPsCQCfZL9M
MbXQZt+cAC6XjskXTJ2/2oo=
=81Sk
-----END PGP SIGNATURE-----

  Réponse avec citation
Vieux 28/07/2007, 00h36   #3
Peter J Ross
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: tcsh Aliases to bash Aliases?

In comp.os.linux.misc on Fri, 27 Jul 2007 18:25:28 -0500, Sam
<sam@email-scan.com> wrote:

> This is a MIME GnuPG-signed message.


....and therefore inappropriate for Usenet.


--
PJR :-)
  Réponse avec citation
Vieux 28/07/2007, 01h50   #4
Sam
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: tcsh Aliases to bash Aliases?

Peter J Ross writes:

> In comp.os.linux.misc on Fri, 27 Jul 2007 18:25:28 -0500, Sam
> <sam@email-scan.com> wrote:
>
>> This is a MIME GnuPG-signed message.

>
> ...and therefore inappropriate for Usenet.


It is very much appropriate. It is true that there are still occasional old
fogeys around, who, for some reason, choose to believe that they still live
in the 1970s, and the Internet that's not polluted by all those furriners
that post messages that contain funny-looking characters, and stubbornly
stick to using obsolete mail software that's never been updated to implement
modern Internet standards.

But, fortunately, that's a small, small minority, and the rest of the world
has moved on and joined the 21st century, and adopted modernized and revised
standards.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)

iD8DBQBGqpLYx9p3GYHlUOIRAuXyAJ9GNW+YXxEUTOzxneGtwb Bl5f94pwCeLl37
b85rkP+HVb9QURBJ6AA+/rU=
=Fipj
-----END PGP SIGNATURE-----

  Réponse avec citation
Vieux 28/07/2007, 19h26   #5
Chris F.A. Johnson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: tcsh Aliases to bash Aliases?

On 2007-07-27, qquito wrote:
> Dear Everybody:
>
> Aliases with arguments do not work under the shell Bash, but I have
> used a number of such aliases under tcsh, and the following is a few
> examples:
>
> (1) alias agrep 'grep \!:1 /myhome/.addresses' (1
> argument)
> (2) alias fd 'find /myhome/work/xyz -name \!:1 -print' (1
> argument)
> (3) alias t2ps 'enscript -j -U 2 -C -G --word-wrap -o \!:2 \!:1' (2
> arguments)
>
> How would you convert the above 3 examples into scripts that can be
> used under bash?


Use functions, e.g.:

t2ps()
{
enscript -j -U 2 -C -G --word-wrap -o "$2" "$1"
}

> Additionally, can you put the scripts in one single file


Put them in your ~/.bashrc (or ~/.bash_profile, depending on how
your shells are invoked, or whether the former is sourced by the
latter), or put them in a separate file and source that from one
of the aforementioned files.

> with each one occupying one line?


Why would you want them each on a single line? Bash is a
Bourne-type shell, and all Bourne shells can have compound commands
spread over more than one line.

You can do it, and with those simple functions, it wouldn't be too
bad:

agrep() { grep "$1" /myhome/.addresses; }

--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell/>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
  Réponse avec citation
Vieux 28/07/2007, 19h28   #6
Chris F.A. Johnson
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: tcsh Aliases to bash Aliases?

On 2007-07-27, Peter J Ross wrote:
> In comp.os.linux.misc on Fri, 27 Jul 2007 18:25:28 -0500, Sam
><sam@email-scan.com> wrote:
>
>> This is a MIME GnuPG-signed message.

>
> ...and therefore inappropriate for Usenet.


Nonsense; the message isn't encoded, and a good newsreader can hide
the GPG signatures.

--
Chris F.A. Johnson, author <http://cfaj.freeshell.org/shell/>
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
===== My code in this post, if any, assumes the POSIX locale
===== and is released under the GNU General Public Licence
  Réponse avec citation
Vieux 29/07/2007, 05h46   #7
qquito
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: tcsh Aliases to bash Aliases?

Thank you, Chris, Sam and other for your replies! I just tried them
and they work! Thanks a lot! --Roland

> Use functions, e.g.:
>
> t2ps()
> {
> enscript -j -U 2 -C -G --word-wrap -o "$2" "$1"
>
> }
> > Additionally, can you put the scripts in one single file

>
> Put them in your ~/.bashrc (or ~/.bash_profile, depending on how


  Réponse avec citation
Vieux 29/07/2007, 17h50   #8
Art Werschulz
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: tcsh Aliases to bash Aliases?

Hi.

You might also want to consider cshtobash, which you can find via
Google.
--
Art Werschulz (agw STRUDEL comcast.net)
207 Stoughton Ave Cranford NJ 07016
(908) 272-1146
  Réponse avec citation
Vieux 29/07/2007, 18h32   #9
Jolly Roger
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: tcsh Aliases to bash Aliases?

On 2007-07-29 11:50:23 -0500, Art Werschulz <agw@comcast.net> said:

> You might also want to consider cshtobash, which you can find via
> Google.


Who me? Why?

--
Apply rot13 to my e-mail address before using it.

JR

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 09h43.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,16972 seconds with 17 queries