Hi ,I have this simple code,why is not working
thanks
#!/bin/csh
set res=find ./ -name "*.bash" | wc -l
$res > result.txt
Hi ,I have this simple code,why is not working
thanks
#!/bin/csh
set res=find ./ -name "*.bash" | wc -l
$res > result.txt
I think you have to put things in backticks to get their value into a variable like that?
In any case why wouldn't you just
find ./ -name "*.bash" | wc -l > result.txt
This is ONLY to answer your question.
#!/bin/csh
set res="find . -name *.bash | wc -l"
$res > result.txt
Thank you ,but when I do that it gives me
set: No match
set res='find . -name "*.bash" | wc -l'
eval "$res" > result.txt
Thanks for the respond,but it doesnt work ,if I run the find part it gives me 25,the whole script gives me Command not found:wall:
I created some ".bash" files in a couple of directories under my current directory.
% find . -name "*.bash" | wc -l
5
% set res='find . -name "*.bash" | wc -l'
% eval "$res"
5
It works fine also in a script. Perhaps your script is cding to another directory? Post the entire script here.
edit: You changed your post from "it gives me 0" to "it gives me Command not found". Post the script.
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
#!/bin/csh
set res=`find . -name "*.bash" | wc -l`
eval "$res" > result.txt
,
You're using backquotes around the assignment. It should be single quotes.
#!/bin/csh
set res=`find . -name "*.bash" | wc -l`
eval "$res" > result.txt
#!/bin/csh
set res='find . -name "*.bash" | wc -l'
eval "$res" > result.txt
$ rm -f result.txt
$ ./MyTest
Hello from .cshrc
$ cat result.txt
5
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
pipe the column of words to sed:
if it is in a file:
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:
somecoommand | sed 's/.*@//g' > outputfile
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
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.
Thanks a lot ,and another question:p,how can I replace certain word in text with diferent one
You can do that using, among others, sed.
If the word is in a variable, you can do it natively using the shell, as you could for a file, without sed.
But, as you're using C-shell, that's probably not possible
Thanks for the help
cat is not necessary there, since sed can read the file without any help
sed 's/Ali/Mali/' empl.txt
It sends the whole file with the changes made to stdout (screen)
sed -n 's/Ali/Mali/p' empl.txt
It sends only the lines changed to stdout
sed 's/Ali/Mali/' empl.txt > empl.txt.new && mv empl.txt{.new,}
It sends the processed data to a new file named empl.txt.new and then deletes the old file and rename the new as the old file