Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Display lines after match is found within specified range Post 302721009 by Skrynesaver on Thursday 25th of October 2012 05:15:18 AM
Old 10-25-2012
Code:
~/$ perl  -ne '$n3 = $_ if $nm;
  print "$1 : $n3" if ( ( /^REF\*D9\*([\d]+)$/ ) && ($1 >= 1001)&& ($1 <= 1100) );
  $nm=/^NM1\*85$/;
' file

Should do what you require
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Grep and display n lines after the match is found.

Hello, How do I use grep to find a pattern in a list of file and then display 5 lines after the pattern is matched Eg: I want to match the string GetPresentCode in all files in a folder and then see 4 lines following this match. I am not sure if grep is what should be used to achieve. Thanks!... (3 Replies)
Discussion started by: cv_pan
3 Replies

2. UNIX for Dummies Questions & Answers

awk display the match and 2 lines after the match is found.

Hello, can someone help me how to find a word and 2 lines after it and then send the output to another file. For example, here is myfile1.txt. I want to search for "Error" and 2 lines below it and send it to myfile2.txt I tried with grep -A but it's not supported on my system. I tried with awk,... (4 Replies)
Discussion started by: eurouno
4 Replies

3. UNIX for Dummies Questions & Answers

Display n lines before match found

I have a file with following data A B C D E F G H I K L M N and search pattern is G Expected output (3 Replies)
Discussion started by: nsuresh316
3 Replies

4. UNIX for Dummies Questions & Answers

Display n lines after match found and other line

I have a file like this DoctorName Address1 Address2 DOB InsuredName Address1 Address2 DOB PatientName Address1 Address2 DOB ClaimNo1 DoctorName Address1 Address2 DOB InsuredName (2 Replies)
Discussion started by: nsuresh316
2 Replies

5. UNIX for Dummies Questions & Answers

How to display lines by range specified?

My input file is N3*123 ABC FLATS~ REF*D9*10000000001~ N3*223 ABC FLATS~ REF*D9*10000000002~ N3*323 ABC FLATS~ REF*D9*10000000003~ N3*423 ABC FLATS~ REF*D9*10000000004~ N3*523 ABC FLATS~ REF*D9*10000000005~ N3*623 ABC FLATS~ REF*D9*10000000006~ N3*723 ABC FLATS~ REF*D9*10000000007~ N3*823... (2 Replies)
Discussion started by: nsuresh316
2 Replies

6. Shell Programming and Scripting

Grep range of lines to print a line number on match

Hi Guru's, I am trying to grep a range of line numbers (based on match) and then look for another match which starts with a special character '$' and print the line number. I have the below code but it is actually printing the line number counting starting from the first line of the range i am... (15 Replies)
Discussion started by: Kevin Tivoli
15 Replies

7. Shell Programming and Scripting

Display lines of two date range from syslog file

Hi Guys, I want to display lines from Solaris syslog file but with 2 dates range. I have some similar solution (https://www.unix.com/shell-programming-scripting/39293-grep-log-file-between-2-dates-4.html) which works fine but as you know syslog has different date format (Jan 22) so this is not... (1 Reply)
Discussion started by: prashant2507198
1 Replies

8. Shell Programming and Scripting

Grep multiple exact match, do not display lines

Hi, Need help to grep the following from a file x. I just want to grep exact match not lines and not partial word. CONFSUCCESS CONFFAIL CONFPARTIALSUCCESS >cat x xczxczxczc zczczcxx CONFSUCCESS czczczcczc czxxczxzxczcczc CONFFAIL xczxczcxcczczc zczczczcz CONFPARTIALSUCCESS czczxcxzc ... (4 Replies)
Discussion started by: rajeshwebspere
4 Replies

9. UNIX for Dummies Questions & Answers

awk - (URGENT!) Print lines sort and move lines if match found

URGENT HELP IS NEEDED!! I am looking to move matching lines (01 - 07) from File1 and 77 tab the matching string from File2, to File3.txt. I am almost done but - Currently, script is not printing lines to File3.txt in order. - Also the matching lines are not moving out of File1.txt ... (1 Reply)
Discussion started by: High-T
1 Replies

10. Shell Programming and Scripting

Display match or no match and write a text file to a directory

The below bash connects to a site, downloads a file, searches that file based of user input - could be multiple (all that seems to work). What I am not able to figure out is how to display on the screen match found or no match found" and write a file to a directory (C:\Users\cmccabe\Desktop\wget)... (4 Replies)
Discussion started by: cmccabe
4 Replies
PERLKO(1)						 Perl Programmers Reference Guide						 PERLKO(1)

NAME
perlko - PerlX XXX XXX DESCRIPTION
PerlX XXX XX XX XXXXX ! PerlX 5.8.0XXX XXXX/ISO 10646X XX XXXX XXX XXX. XXXX XXX XXXX XXXX XXX XX XXXX XXXX XXX XX XXX XXX XX XXX XX XXX XXXX XXXXX. XXXXX X XXXX XXX XX XXX XX XX XX - XXX XX XXX, XX XXX, XXX XXX, XXX XX XXXX XXX XX XXXX, XX XX, XXX XX, XXXX XX, XXXX XX, XXXX XX, XX XXXX XX XX X-X XXXX XX XXX XX XX XXX XXX XXX X XX X XX XXX XX XXX XXX XX XXX XXXX X X XX XX XXX XXXX XX XX XXXX XXXX XX XX XX XX XXX XXXX XXXX. PerlX XXXXX XXXXX XX XXX XX XXXXX. XX XXXXX XXX Perl XXXX XXX UTF-8 XXXX X X XX, XX XXX XXX(XX XX, XXX, index, substr)X XXX XX XX XXXX XX XXX XXXXX. (X XXX XX perlunicode XXXX XXXXXX.) XXXXX XX XXXX XX XX XXX XXX, XXX XX XXX XX XX/X XXX XXXXX XXXX XX XX XXXXX X XXXX XXX XXX XX XX XX 'Encode'X XXXXX. XXXX 'Encode'X XX XXX XXX XXX XXX XX X X XXXX. 'Encode'X XXX XX XXX XXXX XXXXX. euc-kr US-ASCIIX KS X 1001X XX XX XXXXX XXX (XX XXXXXX XX.) KS X 2901X RFC 1557 XX. cp949 MS-Windows 9x/MEXX XXX XX XXX. euc-krX 8,822XX XX XXX XX XX. aliasX uhc, windows-949, x-windows-949, ks_c_5601-1987. X XXX XXX XXXX XX XXXXX, Microsoft XXXX CP949X XXX XXX XX. johab KS X 1001:1998 XX 3XX XXX XXX. XX XXXXX cp949X XXXXX US-ASCIIX KS X 1001X 8,822XX XX XXX XX XX. XXX XXX XX XX. iso-2022-kr RFC 1557XX XXX XXX XXX XX XXX XXXXX US-ASCIIX KS X 1001X XXXXX XX XXX euc-krX XXX XXX XXX XX. 1997-8X XXX XXXX X XX XX XXX XXX XX. ksc5601-raw KS X 1001(KS C 5601)X GL(X, MSBX 0XX X XX) X XXX XX XXX. US-ASCIIX XXXX XX XXXX XXX XX X11 XXX XX XXX (ksc5601.1987-0. '0'X GLX XXX.)XX XXX XX XXXXX XX XX. KS C 5601X 1997X KS X 1001X XXX XXXX. 1998XXX X XX (XXX XXX XX XX XX)X XXXX. X XX XX XXX XXX XXXX. XX XX, euc-kr XXXXX X XXX UTF-8X XXXXX XXX XX XX XXX. perl -Mencoding=euc-kr,STDOUT,utf8 -pe1 < file.euckr > file.utf8 XXXX XXX XX X X XXXX. perl -Mencoding=utf8,STDOUT,euc-kr -pe1 < file.utf8 > file.euckr XX XXX XX XXXX X X XXX Encode XXX XX XXXX PerlXX XX piconvX PerlX XX XXXX. X XXXX X X XXX piconvX UnixX XX iconvX XXX X XXXX. X XXXX XXX XXXX. piconv -f euc-kr -t utf8 < file.euckr > file.utf8 piconv -f utf8 -t euc-kr < file.utf8 > file.euckr X, 'PerlIO::encoding' XXX XX XXX XXXX XXX XX XX (XXX XXX XXX) XXX XX X X XXXX. #!/path/to/perl use encoding 'euc-kr', STDIN => 'euc-kr', STDOUT-> 'euc-kr', STDERR=>'euc-kr'; print length("XX"); # 2 (X XXXX XX XX XXX XX) print length('XX'); # 4 (XX XXXX XXX XX XXX XX) print index("XX, XXX", "X"); # -1 ('X'X XX) print index('XX, XXX', 'X'); # 7 (8XXX 9XX XXXX 'X'X XXXX XXX.) X XXX XX XXX... PerlX XXXX XXX XXX XXX XX XX XX, X XXX XX Perl XX X XXX XXXX XX, EncodeX XXX XX XX XX XX X XXXX. XX X XXX XX XX XXX XX XXXX. Perl XX XX XXX XXX XX XXX XXX XX XXX XXXX. X XXX XX XXX XX XXX XX XXXX XX XX XXXX. <http://www.perl.com/> O'ReillyX Perl X XXX <http://www.cpan.org/> Comprehensive Perl Archive Network <http://lists.perl.org/> Perl XXX XXX. XX XXX XXX perl-unicodeXX 'Encode'X XX XXX. PerlX X XX XXXXX XXX X X XX XXX XX XXX <http://www.perl.or.kr/> Perl XX XXX XX <news:han.comp.lang.perl/> XXX Perl XX XX <http://www.hanb.co.kr/search/searchResult.html?keyword=perl> O'ReillyXX XX XXX Perl XX XX <http://www.perlschool.net/> Perl XX XX X XX, XX XX, XX XX XXX XX <http://www.perl.co.kr> PerlX XXX CGI, DB, XX XX XX XX X XX XX XXXX X XXX XXX XX XX <http://www.unicode.org/> XXXX XXXX. <http://std.dkuug.dk/JTC1/SC2/WG2> XXXXX UnicodeX XX ISO XXX ISO/IEC 10646 UCS(Universal Character Set)X XXX ISO/IEC JTC1/SC2/WG2X X XXX. <http://www.cl.cam.ac.uk/~mgk25/unicode.html> XXX/XXXXX XXXXX UTF-8 XXX XX XXX(FAQ) http://wiki.kldp.org/Translations/html/UTF8-Unicode-KLDP/UTF8-Unicode-KLDP.html <http://wiki.kldp.org/Translations/html/UTF8-Unicode- KLDP/UTF8-Unicode-KLDP.html> XXX/XXXXX XXXXX UTF-8 XXX XX XXX(FAQ)X XXX XX SEE ALSO
Encode, Encode::KR, encoding, perluniintro, perlunicode AUTHORS
Jarkko Hietaniemi <jhi@iki.fi> XXX <jshin@mailaps.org> perl v5.16.2 2012-10-11 PERLKO(1)
All times are GMT -4. The time now is 11:58 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy