Solved

aliases

Posted on 1998-09-17
3
152 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
  • 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
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…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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.

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now