Solved

aliases

Posted on 1998-09-17
3
162 Views
Last Modified: 2010-04-21
How do I create an alias in my .cshrc file? I am trying to create the following alias:
alias nc "niscat hosts | grep something | awk '{print $1}'"

When I type "alias" at the prompt I see:
nc    niscat hosts | grep something | awk '{print }'

When type at the command prompt it works fine, but inside a
script file like .cshrc, the $1 is translated as a NULL variable since no parameters were passed to .cshrc. I am unsure how to use $1 inside a script for awk's print statement.
0
Comment
Question by:carydb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
junfeb earned 50 total points
ID: 2007018
Why don't you try this as the cshrc prompt -
alias nc "niscat hosts| grep something | awk '{print "\$1"}'"

This produces alias to be  
niscat hosts| grep something | awk '{print $1}'

Thanks.
0
 
LVL 3

Expert Comment

by:junfeb
ID: 2007019
P.S. It works fine in the .cshrc file as well .
0
 

Author Comment

by:carydb
ID: 2007020
Thanks junfeb! Your suggestion works fine. I guess you can tell I kinda new to unix.:)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question