Skip to content
Advertisement

How to write an alias in csh/tcsh that can write one file with shebang?

I want to write one script with my alias but not able to add bang line in my script with echo command. I tried these ways:

JavaScript

If I run these lines without alias then they work for me.

JavaScript

With direct typing and using command I’ll get data in file cshCMD.csh as:

  • #!/bin/csh
  • ncl

while when I use alias on command line as

JavaScript

I got this message :

JavaScript

Advertisement

Answer

You need a ! in the expansion of your alias, so you must use \! when defining it. The first backslash disappears during processing of the alias-defining command and the second one protects the ! when the alias runs.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement