HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Deleting patterns in a file
Operating System - HP-UX
1827687
Members
3575
Online
109967
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
11-02-2006 04:11 PM
11-02-2006 04:11 PM
Deleting patterns in a file
Hi to all.,
My text file looks like this...
This is the Starting of the File
Arg1
Arg2
Comments XYZ
This is the contiinuation of the File
Do an if statement for Conditions
Arg3
Arg4
Comments ABC
exit
I want to delete the table between the pattern &
So my output after deleted the table will looks like...
This is the Starting of the File
This is the contiinuation of the File
Do an if statement for Conditions
exit
I am breaking my head from last 2 days for this issue.. Any body expert in scripting help me give a conclusion.
Thanks & Regards
Suseendran .A
My text file looks like this...
This is the Starting of the File
Arg1
Arg2
Comments XYZ
This is the contiinuation of the File
Do an if statement for Conditions
Arg3
Arg4
Comments ABC
exit
I want to delete the table between the pattern
So my output after deleted the table will looks like...
This is the Starting of the File
This is the contiinuation of the File
Do an if statement for Conditions
exit
I am breaking my head from last 2 days for this issue.. Any body expert in scripting help me give a conclusion.
Thanks & Regards
Suseendran .A
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2006 04:29 PM
11-02-2006 04:29 PM
Re: Deleting patterns in a file
perl -ne '$skip = 0 if /^
Enjoy,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2006 10:10 PM
11-02-2006 10:10 PM
Re: Deleting patterns in a file
Hi,
an awk solution:
awk '!skip {print}
$1 == "" {skip=1}
$1 == "" {if(skip) print;skip=0}' your/file
mfG Peter
an awk solution:
awk '!skip {print}
$1 == "
$1 == "
mfG Peter
The Universe is a pretty big place,
it's bigger than anything anyone has ever dreamed of before.
So if it's just us, seems like an awful waste of space, right?
Jodie Foster in "Contact"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2006 10:42 PM
11-02-2006 10:42 PM
Re: Deleting patterns in a file
[ For a short while there was a duplicate entry for this topic to which I also replied.
That reply was still in my paste buffer, so here is it is again. Hein. ]
----
For fun, a minor variation on my earlier answer:
perl -ne "$x=0 if /^
The trick here agains is to test for
The "$x or print" is a litte cute.
Perl tests $x, if it is one, then the total result is true and thus it does nto need to print. If it is false (initial state) the print must be done to find the result of the total expression.
The /^
Regards,
Hein.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Support
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP