alias in CSH


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting alias in CSH
# 1  
Old 09-24-2008
alias in CSH

Hello guys,

I want to use an alias as an sub function in the script. Here is my issue:
I want to use
Code:
exsit_en <pattern> <file>

to indicate that if the <file> contains <pattern> the expression returns 1, and vice versa.
But in the alias I used as follows, the $status alway is 0. Can someone provide a solution about this?

Code:
alias exsit_en 'eval " grep -i \!:1 \!:2 >& /dev/null \\
                        if ( $status == 0 ) then \\
                                echo 1  \\
                        else    \\
                                echo 0  \\
                        endif " '

# 2  
Old 10-11-2008
Old unanswered question about CSH aliases...

Can someone help this poster please?
# 3  
Old 10-11-2008
Try:

Code:
alias exsit_en 'grep -i \!:1 \!:2>&/dev/null&&echo 1||echo 0'

# 4  
Old 10-11-2008
Quote:
Originally Posted by otheus
Can someone help this poster please?

http://www.grymoire.com/Unix/CshTop10.txt
Csh
Csh Programming Considered Harmful
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

IP Alias

Quick question Have a AIX system that has been up for years with a 192.9.x.x IP scheme and we want to add a second IP to the system. I setup the second IP 10.1.x.x as an alias via smit. Since these two IP's are on different VLANs will this be an issue? Reason I ask is that I cannot ping... (3 Replies)
Discussion started by: Chrisp
3 Replies

2. Shell Programming and Scripting

Changing file extension in csh alias

I want to type only the filename of a gcc source that has ".syn" as an extension and copy it, changing the extension to ".c" so it can be compiled. I do it as follows: if (-e $1.syn) then /bin/cp $1.syn $1.c endif This works fine, but if I want to repeat the compilation by... (1 Reply)
Discussion started by: ygmwayne
1 Replies

3. UNIX for Dummies Questions & Answers

Create alias files (not alias commands)

If one: $ find -name 'some expression' -type f > newfile and then subsequently wants to create an alias file from each pathname the find command retrieved and the > placed within 'newfile', how would one do this? Ideally, the newly created alias files would all be in one directory. I am... (3 Replies)
Discussion started by: Alexander4444
3 Replies

4. UNIX for Dummies Questions & Answers

alias

Hi, I have created alias in UNIX environment (ie in .cshrc file). But when i use the alias in the UNIX script, getting an error message as that is not found. But when i use that alias, outside the script it is working fine. Let me know if you need more details For example: alias cderror... (6 Replies)
Discussion started by: Naveen_5960
6 Replies

5. UNIX for Dummies Questions & Answers

Help with Alias

Hi, I have a software package consisting of a group of BASH shell scripts. There is a master script which calls a series of subscripts. To run the software users must open the master script, modify and save it, and then run it. To open the script you can either double-click on it, or you can... (2 Replies)
Discussion started by: msb65
2 Replies

6. UNIX for Dummies Questions & Answers

alias help

Hello again, what does \!* do int his line alias lookup 'grep -i \!* who.is.who' Thanks! (1 Reply)
Discussion started by: kris888
1 Replies

7. UNIX for Dummies Questions & Answers

alias

i used 'alias' command for a set of daily used long commands. But i noticed they are gone once i log out of the ssh session. Can any one plz let me know if there is a way to set it permanently for my user. (1 Reply)
Discussion started by: pharos467
1 Replies

8. Shell Programming and Scripting

csh failing to call an 2 embedded csh script

I have an extraordinary problem with a csh script.....(feel free to berate the use of this but I'm modifying an existing bunch of them) Anyway, I have a master csh script which in turn calls a second csh script. This second csh script is below. Within this second script are two compiled C++... (1 Reply)
Discussion started by: pollsizer
1 Replies

9. Shell Programming and Scripting

please help me regarding alias

Dear All, I have given alias to run a script which will calculate memory and cpu utilization as "utils" in my bash shell. Even i have given this entry in .profile and .bashrc in my home directory. It is working fine. Now my question is that I want to use this alias in... (17 Replies)
Discussion started by: naree
17 Replies

10. Shell Programming and Scripting

Alias

how implement functionality alias in the same way as in csh? (use Bourne type sh or bash) (3 Replies)
Discussion started by: sunhata
3 Replies
Login or Register to Ask a Question