cshell script problem


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting cshell script problem
# 8  
Old 02-06-2011
I misstype the code the first time.now this is the code and its printing
Command not found
if I put single quotes ' instead of ` gives me No match

Code:
 
 
#!/bin/csh
set res=`find . -name "*.bash" | wc -l`
eval "$res" > result.txt

,
# 9  
Old 02-06-2011
You're using backquotes around the assignment. It should be single quotes.

Code:
#!/bin/csh
set res=`find . -name "*.bash" | wc -l`
eval "$res" > result.txt

Code:
#!/bin/csh
set res='find . -name "*.bash" | wc -l'
eval "$res" > result.txt

Code:
$ rm -f result.txt

$ ./MyTest          
Hello from .cshrc

$ cat result.txt
       5

# 10  
Old 02-06-2011
Thanks,if I put single quotes gives me no mach ,if I put back quotes and print $res,gives me the right result in my case 25
but the next line eval "$res" > result.txt
print Command not found

---------- Post updated at 07:16 AM ---------- Previous update was at 06:55 AM ----------

I found the solution ,I simply had to echho the var

echo $res > result.txt


Thanks for the help !!


I have another question_____how can I cut sample@yahoo.com up to the @ simbol ______ to print just yahoo.com ,the command has to work for a column of words with different length
Thanks again

Last edited by lio123; 02-06-2011 at 08:22 AM..
# 11  
Old 02-06-2011
pipe the column of words to sed:

if it is in a file:
Code:
cat mailfile | sed 's/.*@//g' > outputfile

Do NOT redirect to the same file you read from because you will end up with a blank file.
if it is coming from some other command:

Code:
somecoommand | sed 's/.*@//g' > outputfile

# 12  
Old 02-06-2011
MySQL

Thank you very mach,could you show me how to print the first part of the email before @ sample@yahoo.com to print just sample
Thanks again
# 13  
Old 02-06-2011
Code:
 
cat file | awk -F\@ '{print $1}' > newfile

The above command is the first thing that comes to mind. There are other ways to do it, its just the way I find easiest.
# 14  
Old 02-06-2011
Thanks a lot ,and another questionSmilie,how can I replace certain word in text with diferent one
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Assigning any number to the variable in cshell script

Hello Guys, I would like to ask you for a favor. Could you please help me how can I assign any number as the parameter to a, from stdin (-c), in the following command line by using the 'switch' in a script? awk '$8>a {print "File name:" $5,$8}' I would also appreciate if you can share any... (1 Reply)
Discussion started by: Padavan
1 Replies

2. UNIX for Advanced & Expert Users

Unable to call a script from another script in cshell

Hi, I am unable to call one script from another script in c shell on windows SUA environment. Please find below code , File1 āTmp.csh: #!/bin/csh setenv PATH "${PATH}:.:$TOP/bin:$TOP/RMBIN/bin:$GP_SUA/:$INTERIX_ROOT" echo "hi1" . /tmp1.csh File2ātmp1.csh ... (6 Replies)
Discussion started by: gthangav
6 Replies

3. UNIX for Dummies Questions & Answers

this cshell script does not work ??

Hi I am trying to put the following commands that i have to type manually at the cshell prompt into a cshell script startup.csh which is copied below echo $DISPLAY xhost + rsh ba08lo01 module load incisiv/102/10.20.035 setenv DISPLAY $DISPLAY When i run the script with source command... (2 Replies)
Discussion started by: kaaliakahn
2 Replies

4. Shell Programming and Scripting

Script cShell - help!!

Hello everyone! i'm new in this forum and I'm here because I have a huge problem with a csh script. Here the problem: I have to write a script that check the system status, more precisely I have to check if there are processes with TIME > 3 hours and if such processes exists I must send a mail... (3 Replies)
Discussion started by: TheBeefEater
3 Replies

5. Shell Programming and Scripting

CShell if statement

If I want to compare two string variables in csh how do I correctly implement it. For example I'm checking if on cmdln the $1 == -r do something. if($1 == -r) then code.... However when I run it I just get an error message "if: Missing file name". Any suggestions? (1 Reply)
Discussion started by: ROFL
1 Replies

6. Shell Programming and Scripting

CShell Syntax Problem

Hi guys, Basically I'm trying to write a CShell script that calls an awk script on a given directory (given in command-line). I keep getting a syntax error with my code though: #!/bin/csh set dir = $ARGV foreach file ( $dir/* ) set output = 'awk -f /Desktop/aal $file' echo... (3 Replies)
Discussion started by: ROFL
3 Replies

7. UNIX for Dummies Questions & Answers

Regarding Decimals in Cshell

Hello... I am new to unix and I am wondering if in a C-shell script , Are we supposed to use only whole numbers........ for example..if a program needs to calculate the average of some numbers........ @ avg = (($1 +$2 + $3)/3)) is returning a whole number.........How can a decimal be achieved... (1 Reply)
Discussion started by: ravindra22
1 Replies

8. UNIX for Dummies Questions & Answers

grep in Cshell

Hi Everyone, I'm facing a problem using grep in Cshell. This is what i'm trying to do: grep "abc" somefile VAR="$?" echo $VAR somefile contains: abc def ghi Now, should'nt my output be 0 (Zero) I'm getting 1 (One) Can you please help me out. Thanks in advance :) G1 (2 Replies)
Discussion started by: jeevan_fimare
2 Replies

9. Shell Programming and Scripting

How to make a cshell (csh) script interactive

Experts, I tried to make my cshell script interactive by asking the user for password and trying to read the input using the "read" command. I have been unsuccessful so far. Do you have any idea ? Thanks Jim (2 Replies)
Discussion started by: jimmynath
2 Replies

10. Shell Programming and Scripting

help with cshell script to read 1 or more lex files

taskes one or more .l files and compiles them #!/usr/bin/csh #while loop to carry on asking user to enter the files while $number!=0 echo "enter file name" #check to see if file ends with .l #if file ends with .l compile lexx.yy.c file for each file this is how i think it needs... (1 Reply)
Discussion started by: homerj546
1 Replies
Login or Register to Ask a Question