serach file using awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting serach file using awk
# 1  
Old 08-28-2007
serach file using awk

Hi,
I was able to print lines when search for specific string using awk but i want to print when search for two different strings using awk instead of doing two times (Print lines only contain "Insert Records and Insert into" not between lines)

Ex:
awk '/Insert Records./' a4.log

It displaying all lines strat with Insert Records
ex:

Insert records total:4
Insert records total:6
Insert records total:8

awk '/Insert into./' a4.log
ex:
Insert into t1
Insert into t2
Insert into t3

Thanks inadvance
Mohan
# 2  
Old 08-28-2007
Code:
awk '/firstpattern/ || /secondpattern/ { print }' filename

# 3  
Old 08-28-2007
Thanks for your reply.

Thanks ,
Mohan
# 4  
Old 08-28-2007
Replace string in multiple files

Hi,

One more question ,I Have 10 files ,I need replace $INPUT_LOCATION with $INPUT_LOCATION_upd .using sed command do it single file .How can change all files in single shot

sed -s'/old/new' file1

Thanks,
Mohan
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to get a value from a file and serach that value filename in a dir?

buddies, my requirement would be as follows, I have a file called test.txt and content of it would be yahoo gmail hotmail and i want to search a file name called "yahoo.html" (first line of test.txt) and then "gmail.html" and then "hotmail.html" in a /home/test dir. Any idea... (8 Replies)
Discussion started by: natraj005
8 Replies

2. Shell Programming and Scripting

Serach a string for multiple occurrences in a file and cut related texts

Hi, I want a help in this forum for my below issue. 1. I have a file where I'm searching for a text . 2. When I get the line where the above string is present I want to cut some texts from the line where the particular string was found. These above two steps will repeat in the... (2 Replies)
Discussion started by: bhaski2012
2 Replies

3. UNIX for Dummies Questions & Answers

Serach a pattern

Hi, I am trying to find a particular patter in multiple UNIX files (also contain system files,hidden files and normal files) i am now using CMD: egrep -ali 'pattern' * i am not getting the required result, i just need files path and finename Naveen (3 Replies)
Discussion started by: Naveen_5960
3 Replies

4. Shell Programming and Scripting

How to serach for Values grater tan 4 digits in a file using Awk Command

Dear All iam looking for a help in how to search for values grreater than 4 numbers. I run the below commad but its still not working awk '{ print $2 " " $5 }' AllRecords | grep "+008" | grep "length" > 4 Can any one help me. Regards Kadir (1 Reply)
Discussion started by: samura
1 Replies

5. Shell Programming and Scripting

serach and replace a specific pattern or value in a xml file

can some one help me with a perl command i have to search and replace a version from a xml-file so i use in a ksh script a command like this ssh $GLB_ACC@$GLB_HOST "/usr/contrib/bin/perl -pi -e "s/$curVersion/$new_Version/g" $Dest_dir/epi.xml" this command worked so far, but the problem... (1 Reply)
Discussion started by: kiranreddy1215
1 Replies

6. UNIX for Dummies Questions & Answers

Need to serach if a new line character exists on the last line in a file

I have a file in which I need to search if a new line character exists on the last line in the file. Please let me know how can I achieve it using Unix commands? (10 Replies)
Discussion started by: sunilbm78
10 Replies

7. Shell Programming and Scripting

serach and replace file name in the path in a remote xml file

hi every one , here is my problem !! i have to run my script from an account and update the result in a xml file located on a different account. i use existing ssh keys to do it remotely for example the tags looks like this <PropertyValueList... (1 Reply)
Discussion started by: kiranreddy1215
1 Replies

8. UNIX for Advanced & Expert Users

Serach and delete

Hi, This is the format of the file that i have CompanyNumber Run Date: 8/3/2006 6:22:15PM Address: Person: A03120 SP SNNu 100 1 200 2 CompanyNumber ... (3 Replies)
Discussion started by: kkm_job
3 Replies

9. Shell Programming and Scripting

Case-insensitive serach with awk

Is there any way to do case insensitive search with awk for the below statement: month1=`awk '/month/' ${trgfile} | cut -d"=" -f2` the "month" could come as Month, mOnth,MONTH etc. in a file. Now I am looking for "month".... Thanks, AC (4 Replies)
Discussion started by: acheepi
4 Replies

10. UNIX for Advanced & Expert Users

text serach in unknown file

Can any one tell me if there is an easy way to find a text in an unknown file name in a dierectory. I'm trying to search for the text "where is john going" from a file whose name I do not even know. There are about 1000 files in that directory and one of the files has this text in it. Can... (11 Replies)
Discussion started by: ted
11 Replies
Login or Register to Ask a Question