Visit Our UNIX and Linux User Community


searching in a while where a word is not there.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting searching in a while where a word is not there.
# 1  
Old 08-20-2009
searching in a while where a word is not there.

Hi,

I am new to unix, pls help

I have a file suc_Logfile file. liek this.

output
success
success
abc

Now i need to generate a file in shell script where it shows only abc.
Now i am doing like this
grep "^successfully\|$" $suc_Logfile >> $Final_Suc
Pls help.

Thanks,
Sailaja
# 2  
Old 08-20-2009
Quote:
Originally Posted by sailaja_80
...
I have a file suc_Logfile file. liek this.

output
success
success
abc

Now i need to generate a file in shell script where it shows only abc.
Now i am doing like this
grep "^successfully\|$" $suc_Logfile >> $Final_Suc
...
What's the point of trying to grep "successfully" when it isn't even present in your file ?

Do you want to grep the word "successfully" ?
Or the word "abc" ?

tyler_durden
# 3  
Old 08-20-2009
Thanks for your reply.

I want to grep for the word abc.

---------- Post updated at 06:12 PM ---------- Previous update was at 06:12 PM ----------

sorry that success was a typo error. its actually successfulll.
# 4  
Old 08-20-2009
Quote:
Originally Posted by sailaja_80
...
I want to grep for the word abc.
....
Then guess what word you'll want to use with grep.

tyler_durden
# 5  
Old 08-20-2009
Hi Durden , I got confused. let me write it clearly here.

I have a outfile generated like this.
DB20000I The SQL command completed successfully.
DB20000I The SQL command completed successfully.
abc
DB20000I The SQL command completed successfully.
DB20000I The SQL command completed successfully.
def
DB20000I The SQL command completed successfully.
DB20000I The SQL command completed successfully.
ghi
DB20000I The SQL command completed successfully.
DB20000I The SQL command completed successfully.
jkl

Now i need the output as
abc
def
ghi
jkl

sorry for the confusion.

THanks,
# 6  
Old 08-21-2009
Hi Sailaja,

Below command can be used to remove lines with "successfully" from your output.

Code:
grep -v "successfully" file

Regards,

Ranjith
# 7  
Old 08-21-2009
Code:
sed "/successfully/d" file.txt


Previous Thread | Next Thread
Test Your Knowledge in Computers #206
Difficulty: Easy
Exterior Gateway Protocol (EGP) is a modern, widely used, routing protocol.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

start searching a word from the particular record on the result of first occurence change the value

Hi, I need a script to start searching a word from the particular record on the result of first occurence i need to change the value in that record. I have a input file like this <properties> <add key="DeliveryWithinDay" value="False" /> <add key="ABC" value="23:00:00 PM" /> <add... (5 Replies)
Discussion started by: NareshN
5 Replies

2. Shell Programming and Scripting

Help with searching a word,find the identifier under which it is there and giving a report

Hi, i have a directory structure which contains few files each. each file in turn has some functions. i'm searching for a word, say 'pen' in all the files present in all the directories. :wall: consider a file file1.c in Dir1. out of the 3 funcs present in this file, func1(pennum) and... (3 Replies)
Discussion started by: i.srini89
3 Replies

3. UNIX for Dummies Questions & Answers

Find EXACT word in files, just the word: no prefix, no suffix, no 'similar', just the word

I have a file that has the words I want to find in other files (but lets say I just want to find my words in a single file). Those words are IDs, so if my word is ZZZ4, outputs like aaZZZ4, ZZZ4bb, aaZZZ4bb, ZZ4, ZZZ, ZyZ4, ZZZ4.8 (or anything like that) WON'T BE USEFUL. I need the whole word... (6 Replies)
Discussion started by: chicchan
6 Replies

4. Shell Programming and Scripting

Searching a word in multiple files

Hi All, I have a issue in pulling some heavy records , I have my input file has 10,000 records which i need to compare with daily appended log files from (sep 1st 2009 to till date) . I tried to use grep fgrep and even sed , but the as time is factor for me , i cannot wait for 5 days to get the... (3 Replies)
Discussion started by: rakesh_411
3 Replies

5. Shell Programming and Scripting

Insert tags in lines after searching for a word

Hi, I am new to Unix and this is my first post on this forum. I am trying to convert a file into an xml. In my input I want to search for any line that starts with a 'F' and make it a tag in the xml. See below for the input and output. Input : <Payment> <REFERENCE>78</REFERENCE> F123 : ... (7 Replies)
Discussion started by: akashgov
7 Replies

6. Shell Programming and Scripting

can anyone help with shell script command about searching word with grep command?

i want to search in the current directory all the files that contain one word for example "hello" i want to achieve it with the grep command but not with the grep * (2 Replies)
Discussion started by: aintour
2 Replies

7. UNIX for Dummies Questions & Answers

Searching mutiple word - Tuning grep command

Hi all, I have a log file which is more than 1GB, i need to take count from the log file for two strings. i am using the below command but it take a long time to excetue, i need to tune this. Please help me cat /logs/gcbs/gcbsTrace.log | grep -i "ViewStatementBusinessLogic" | grep -c -i... (8 Replies)
Discussion started by: senthilkumar_ak
8 Replies

8. Shell Programming and Scripting

Searching word in a file with awk

Hello everyone! I use a script to query for installed packages with yum (I use RHEL 4 with yum installed) and the output is redirected to a file. My script scan this file to find a package and the version of it. The script works fine until I search for a package name with special characters.... (3 Replies)
Discussion started by: studieu
3 Replies

9. UNIX for Dummies Questions & Answers

searching word in files

hi all i want to search some word in file but i want that it will search in all the files that i have in all the directories i do'nt know the name of the file i know that grep command want some specified file in which command shell i used thanks (2 Replies)
Discussion started by: naamas03
2 Replies

10. UNIX for Dummies Questions & Answers

Searching for key word within a file

Hello, I have a directory that holds all of my matlab codes. I am trying to run a searh on all of the matlab files that have the word "while" written inside the sytax of the code. Looking for all of the times that I did a while loop. Can someone help me do this? Thanks in advance. ... (1 Reply)
Discussion started by: moradwan
1 Replies

Featured Tech Videos