It is currently Tue, 30 Nov 2021 18:19:34 GMT



 
Author Message
 Define Tcsh Alias with $ Character as Regexp
Hi

I often need to move text files between Unix and MS-Win, and edit them.
So, I use the following sed commands to remove or add the
carriage-return "\r" character at end-of-line.

  > sed 's/^M$//' foo.dos > foo.unix
  > sed '/^M$/\!s/$/^M/' foo.unix > foo.dos

The ^M character is entered using Ctrl-j in tcsh (in both bindkey -e and
bindkey -v).  BTW, I don't know why tcsh interprets Ctrl-j for ^M and
Ctrl-m for ^J, whereas csh treats Ctrl-m for ^M.  Anyone?

Since I use the sed commands frequently, I want to define them as
aliases.  So, I attempted the followings, but unsuccessfully.

  tcsh> alias dos2unix 'sed "s/^M$//"'
  tcsh> dos2unix foo.dos
  Illegal variable name.

  tcsh> alias dos2unix 'sed "s/^M\$//"'
  tcsh> dos2unix foo.dos
  Variable name must contain alphanumeric characters.

  tcsh> alias dos2unix 'sed \'s/^M\$//\''
  Unmatched '.

  tcsh> alias dos2unix 'sed \"s/^M\$//\"'
  tcsh> dos2unix foo.dos
  Unrecognized command: "s/^M$//"

  tcsh> alias dos2unix "sed 's/^M$//'"
  Illegal variable name.

  tcsh> alias dos2unix "sed 's/^M\$//'"
  Variable name must contain alphanumeric characters.

I exhausted all my meager Unix knowledge on quoting and escaping.  I
appreciate if anyone can show me the tricks to define the aliases.

FYI, I'm using tcsh 6.03.00 on Solaris 2.5.1.

Thanks.

Hon-Chi

Sent via Deja.com http://www.**-**.com/
Share what you know. Learn what you don't.



 Tue, 20 Nov 2001 03:00:00 GMT   
 Define Tcsh Alias with $ Character as Regexp
(This message mailed and posted)

In article <7j9h8j$oo...@nnrp1.deja.com>,
  Hon-Chi Ng <honchi...@my-deja.com> wrote:

WRT the quoting problem, one possible solution would be
   alias whateveryoucallit 'sed 's/^M\\\$//
but why would you want to define an alias for something that is probably
already built into your system? Try doing a
    man dos2unix
first.

Ronald
--
Ronald Fischer <ronal...@my-dejanews.com>
http://ourworld.compuserve.com/homepages/ronald_fischer/

Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.



 Fri, 23 Nov 2001 03:00:00 GMT   
 
   [ 2 post ] 

Similar Threads

1. Selective Alias using Apache 1.2 regexp?

2. Apache module for regexp Alias/Redirect???

3. gcc #define #define #define

4. How to define aliases on startup


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software