A small script required!!


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers A small script required!!
# 1  
Old 03-10-2010
A small script required!!

Hi All,

I am using korn shell sun solaris 10

What i need is i have to grep one file and if there are any finding then i have set one flag. otherwise continue

Please help

Regards
Arun
# 2  
Old 03-10-2010
Your question, like the subject of the thread is very vague.

Please elaborate.

I've moved your thread to a shell scripting forum, as this is not a Solaris question.
# 3  
Old 03-10-2010
Ok thank you scott.

As i said i need to grep one file for perticular word like "ORA-"
If any rows found with that word then set flag x=1
else
set flag =0
# 4  
Old 03-10-2010
Code:
grep ORA- > /dev/null some_file && x=1 || x=0

# 5  
Old 03-10-2010
Please post the latest version of you script, whether or not it contains syntax errors.

Please post examples of lines from the log which contain the string "ORA-".


This command sequence is not valid in any unix script:
Code:
set flag x=1
else 
set flag =0

It is not possible to guess what you want to do.
Please state in words (not script) what you are trying to do showing example input and example output with a statement about the processing.
# 6  
Old 03-10-2010
actually i meant that in words... not as a script

---------- Post updated at 06:27 PM ---------- Previous update was at 06:20 PM ----------

Thanks scott.. what u said is working for me

If i have many search strings? then? like 'ORA-','Warning','Error'

Please advice
# 7  
Old 03-10-2010
You can use
Code:
grep -E "ORA-|Warning|Error"

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Small help required to create For loop

Hi, I am new to UNIX and have an issue. I need to check that whether a perticular file name exists or not. I wan to do that in loop to avoid number of IF statements. I need to check that if file10.txt exists rename that to file11.txt. if file9.txt exists rename that to file10.txt. : : if... (5 Replies)
Discussion started by: unankix
5 Replies

2. Shell Programming and Scripting

Small Help required for merging two files per line!!!

Hi Guys, Sorry to bother everyone again here, but I ran into a small problem that has been after me for some time now. I have a file called file1.txt and has following content - /folder1/fold/folder 10k /folder167fold/folder 10MB /folder2/fold/folder 10G etc.. etc.. ... (1 Reply)
Discussion started by: rockf1bull
1 Replies

3. UNIX for Dummies Questions & Answers

need help with small script

Hi I have the below file Name=abc Yr=2011 Mon=05 My script should be in such a way that whenever I run it then Month should increment by 1 and if the month is 12 then when I run the script then year should incremented by 1 and month Should become 01(I.e jan) Thanks for the help in... (6 Replies)
Discussion started by: kishu
6 Replies

4. AIX

Need help in a small script

Hello all, could somebody help..? I have following 6 files (with white spaces in their names) This is file This is file1 This is file2 This is file3 This is file4 This is file5 This is file6 I tried to run the below script, and it did not give me desired ouput.. $ for i in `ls -1` >... (7 Replies)
Discussion started by: gsabarinath
7 Replies

5. Shell Programming and Scripting

need a small script

Hello all, i have a batmail process running on my machine(java process). i just need a script we should detect whether the batchnail is running or not.If not it should restart it. Can anyone assist me on this? (1 Reply)
Discussion started by: Rayzone
1 Replies

6. Shell Programming and Scripting

Small shell script help required

Hi Guys, Please can some one explain me the below part of code. In this code what is the use of the line in Bold. COPY=0 if ; then echo "$CONF exists and is non-empty - backing it up" SUFFIX=`date +%Y%m%d%H%M%S` echo "cp -p $CONF $CONF.$SUFFIX" cp -p $CONF... (4 Replies)
Discussion started by: max29583
4 Replies

7. Shell Programming and Scripting

small script help

#!/bin/ksh for i in *.log* do ls $i|sed 's/\.log$//g' | while read file do echo "file $file is Running" >> lls.txt echo "***************">> lls.txt done done ------------------------------------------------------------------ the output is : file AdapterCCProvisioningInterface... (9 Replies)
Discussion started by: ali560045
9 Replies

8. Shell Programming and Scripting

small script

Hi, I am new to unix shell scripting. I just want a little script to check the no. of processes are equal to 8, then echo a successful message otherwise echo a unsuccessful message. Please help. Thanks. (3 Replies)
Discussion started by: everurs789
3 Replies

9. Shell Programming and Scripting

small script help

here is a small script: if ; then echo please enter an argument fi if [ "$1" = "tom"; then a=$1 echo $a fi here is my question. if the script name is j.sh and I run it : j.sh from shell prompt: without a parameter: it prints please enter an argument but if I go with . j.sh (current... (1 Reply)
Discussion started by: rkl1
1 Replies

10. Shell Programming and Scripting

Need help in a small script

Hi all, I have a file of the following format - EXPRPT:SCN:1.1706E+10:SEQ_START:121652:SEQ_END:121664:0 ( This file name is variable and changes daily) Now in the same directory I have another set of files of the format - EXPRPT.log.0001.0000121669 Now what I am trying to do is to ... (2 Replies)
Discussion started by: super_duper_guy
2 Replies
Login or Register to Ask a Question