- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- grep a paragraph ??
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-16-2004 10:10 PM
тАО03-16-2004 10:10 PM
is there a method to filter out (from a text format file) a whole paragraph containing a line with certain pattern(which I serach for) (not only the line)??? this will be too helpful for me in processing large data amounts.
Thanks.
Tamer
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-16-2004 10:14 PM
тАО03-16-2004 10:14 PM
Re: grep a paragraph ??
jer khaerg heiurrgh errhg iuehrg ihreg uhe
erg iuuehr guhre iguhreui hough erhg oehr
jhrg oqhergo hero
h whrego hogh oerhorhjow h owrjt hojro ht
tkj wltrj rttjh rjtho ijrtph wjrthiwj rtoj
rthj owitr TEST jpijrtthpijwtrphjwpiotrh
tijworej otijwpttjoi tjh
itjwprtj prrtjthh pwrtjpwjrttphjwpthowr
irjtpwjtrp rptij rptjhpprtjh pritj wprt
jteypiwjpwt
lt09:/tmp 107 > perl -ne'BEGIN{$/="\n\n"}/TEST/&&print' test.txt
h whrego hogh oerhorhjow h owrjt hojro ht
tkj wltrj rttjh rjtho ijrtph wjrthiwj rtoj
rthj owitr TEST jpijrtthpijwtrphjwpiotrh
tijworej otijwpttjoi tjh
lt09:/tmp 108 >
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-16-2004 10:16 PM
тАО03-16-2004 10:16 PM
Re: grep a paragraph ??
-Karthik S S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-16-2004 10:46 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-17-2004 01:13 AM
тАО03-17-2004 01:13 AM
Re: grep a paragraph ??
how about this:
# cat
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-17-2004 02:49 AM
тАО03-17-2004 02:49 AM
Re: grep a paragraph ??
Thanks a million for your great amazing scripts !!!!!
It is easly done !
Tamer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-18-2018 01:32 PM
тАО04-18-2018 01:32 PM
Re: grep a paragraph ??
Assuming the data is structured so that it's always the line
before and after that you want you can make use of grep's -A (after) and
-B (before) switches to tell it to include the 1 line before the match
and 1 line after it:
For example i'm grepping physical device memory configuration in
dmedecode, I can use the Locator: as anchor point to paragraph i need to
grep.
dmidecode|grep -A 10 -B 8 "Locator:"
The output will be like this:
Memory Device
Array Handle: 0x1000
Error Information Handle: Not Provided
Total Width: 72 bits
Data Width: 64 bits
Size: 8192 MB
Form Factor: FB-DIMM
Set: 1
Locator: Board 1, DIMM 1A
Bank Locator: Not Specified
Type: DDR3
Type Detail: Synchronous
Speed: 1333 MHz
Manufacturer: Not Specified
Serial Number: Not Specified
Asset Tag: Not Specified
Part Number: Not Specified
Rank: 2
Configured Clock Speed: 800 MHz
--
--
---
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-21-2018 02:28 PM
тАО04-21-2018 02:28 PM
Re: grep a paragraph?
> grep's -A and -B
These are only available in gnu's grep.