Sponsored Content
Top Forums Shell Programming and Scripting Matching a block of data sed or ksh Post 302851549 by Akshay Hegde on Monday 9th of September 2013 08:10:33 AM
Old 09-09-2013
I could able to assume your request for some extent

file contains special blocks is named special.txt
Code:
akshay@Lenovo-E49:~$ cat special.txt
The list of characters
bugs bunny
tom and jerry 
Mighty mouse 
Felix the cat
/

file to be matched is named as file3.txt
Code:
</td><td>=</td><td>819BBC99-5A52-CB11-97AC-86FC3869ED64</td></tr></table></td></tr>
 </tbody></table></div>
<div class="indented">
        <div class="indented">
    <table width="100%" class="node" summary="attributes of core">
 <thead><tr><td class="first">id:</td><td class="second"><div class="id">core</div></td></tr></thead>
 <tbody>
The list of characters
bugs bunny
dummy test1
tom and jerry 
Mighty mouse 
Felix the cat
/
<div class="indented">
<table width="100%" class="node" summary="attributes of lenovo-e49">
 <thead><tr><td class="first">id:</td><td class="second"><div class="id">lenovo-e49</div></td></tr></thead>
 <tbody>
    <tr><td class="first">description: </td><td class="second">Notebook</td></tr>
    <tr><td class="first">product: </td><td class="second">34641N3 (LENOVO_MT_3464)</td></tr>
    <tr><td class="first">vendor: </td><td class="second">LENOVO</td></tr>

and assuming that order of line is not important

Code:
akshay@Lenovo-E49:~$ awk 'FNR==NR{special[$0]++;c=NR;next}($0 in special){n++}{if(n==c){print "Yes";exit}}END{if(n!=c)print "No"}' special.txt file3.txt
Yes

Otherwise, please post what you have tried so far, sample input and expected output as and when you request forum for solution ..

Last edited by Scrutinizer; 09-09-2013 at 10:42 AM.. Reason: Tone
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

ksh pattern matching

I try to use the pattern substitution operators as documented in the O'Reilley "Learning the Korn Shell" but it doesn't seem to work as advertised. This works all right: var='Regular expressions rules!' $ echo ${var//e/#} R#gular #xpr#ssions rul#s! The docs says that using !(expr)... (5 Replies)
Discussion started by: ripat
5 Replies

2. UNIX for Dummies Questions & Answers

converting a tabular format data to comma seperated data in KSH

Hi, Could anyone help me in changing a tabular format output to comma seperated file pls in K-sh. Its very urgent. E.g : username empid ------------------------ sri 123 to username,empid sri,123 Thanks, Hema:confused: (2 Replies)
Discussion started by: Hemamalini
2 Replies

3. Shell Programming and Scripting

Pattern matching in ksh

In the Korn shell is it possible to truncate a pattern like this: - ) ]] So that it is not necessary to enter 8 times? (2 Replies)
Discussion started by: steadyonabix
2 Replies

4. AIX

Matching command scroll - ksh

In ksh is there a was to scroll thru all matching commands? For example I executed several commands over several days. Is there a way to scroll thru all the matching 'find' commands only that was executed? No messing with the .history file. Anyway to do this from the command prompt? TIA. (3 Replies)
Discussion started by: Un1xNewb1e
3 Replies

5. Shell Programming and Scripting

Compare two files and get matching data

Hi, Can anyone help me to compare two files and get the matching data... say i have file1 and file2 ... file1 has 300 unique data with that i need to match with file2 to see how may are matching.. file2 have 1000 records. (4 Replies)
Discussion started by: zooby
4 Replies

6. Shell Programming and Scripting

ksh Multiple Pattern Matching Operators

I figured this would be simple, but I am stuck. Variable longpath="/dir1/dir2/dir3/filename.stuff.morestuff.garbage" I want to end up with just "filename.extra.moreextra". So, I want to get rid of the path and .garbage I want to do this with just ksh internals. So, no sed,grep,awk,expr,... (4 Replies)
Discussion started by: Topaz
4 Replies

7. Shell Programming and Scripting

Matching the entries and printing data

Hi all, I have a file with Id which I want to compare it with other file to get the sequence of a particular id. File 1 with ID Q7L8J4 Q676U5 Q8NAA4 Q5TYW2 Q5SQ80 Q5VUR7 Q4UJ75 Q96IX9 Q7Z4T9 Q6NTF7 Q8IZP0 Q9NYB9 Q9P2A4 O14639 Q9ULW3 (5 Replies)
Discussion started by: manigrover
5 Replies

8. Shell Programming and Scripting

Printing a block of lines from a file, if that block does not contain two patterns using sed

I want to process a file block by block using sed, and if that block does not contain two patterns, then that complete block has to be printed. See below for the example data. ................................server 1............................... running process 1 running... (8 Replies)
Discussion started by: Kesavan
8 Replies

9. Shell Programming and Scripting

Need awk/sed command to pull out matching lines from a block

Hi, In order to make our debugging easier in log files, I need this script. My log file will be structured like this : ------Invoking myfile -param:start_time=1371150900000 -param:end_time=1371151800000 for 06/14/2013 <multiple lines here> ..... - Step Sybase CDR Table.0 ended... (3 Replies)
Discussion started by: Lakshmikumari
3 Replies

10. Shell Programming and Scripting

IN Between Data after matching the Pattern

HI , I WANT TO RETRIVE IN BETWEEN DATA FROM PARENTHESIS AND I AM GETTING ERRORS WHILE RUN THE AWK.I HAVE 2 FILES AND WANT TO PROCESS 1ST FILE PATTERN TO 2ND FILE AND WRITES INTO OUTPUT FILE.THIS TIME I AM PUTTING WHERE EXACTLY I AM GETTING ERRORS.SO PLEASE HELP. PATTERN_FILE.TXT --------------... (1 Reply)
Discussion started by: andrew_11
1 Replies
suspend(1)							   User Commands							suspend(1)

NAME
suspend - shell built-in function to halt the current shell SYNOPSIS
sh suspend csh suspend ksh suspend DESCRIPTION
sh Stops the execution of the current shell (but not if it is the login shell). csh Stop the shell in its tracks, much as if it had been sent a stop signal with ^Z. This is most often used to stop shells started by su. ksh Stops the execution of the current shell (but not if it is the login shell). ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
csh(1), kill(1), ksh(1), sh(1), su(1M), attributes(5) SunOS 5.10 15 Apr 1994 suspend(1)
All times are GMT -4. The time now is 07:16 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy