- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script to work on a large file
Operating System - HP-UX
1748148
Members
3511
Online
108758
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
Discussions
Discussions
Forums
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
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
тАО03-31-2011 09:14 AM
тАО03-31-2011 09:14 AM
Script to work on a large file
I need a script to remove header lines of a printing file. For example, I know it started with a identifier GATB, and from the line containing this GATB, I should remove 9 lines. The document has 800+ pages, could you help me to get this script done?
Thanks in advance,
Chushia
Thanks in advance,
Chushia
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-31-2011 05:31 PM
тАО03-31-2011 05:31 PM
Re: Script to work on a large file
This should do it:
COUNT=0
while read LINE
do
echo $LINE | grep GATB > /dev/null
if [ $? = 0 ] ; then
COUNT=1
fi
if [ $COUNT = 0 ] ; then
echo $LINE
else
if [ $COUNT -lt 11 ] ; then
((COUNT=COUNT+1))
else
COUNT=0
echo $LINE
fi
fi
done < input > output
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-01-2011 05:58 AM
тАО04-01-2011 05:58 AM
Re: Script to work on a large file
Thanks for the script. It did not work.
I studied the file again, and found a pattern that the header ends with a dashed line -----------------------
so I used sed to remove them by:
sed '/GATB/,/\-\-\-\-\-\-\-\-\-\-\-\-\-\-/d' < input > output
I studied the file again, and found a pattern that the header ends with a dashed line -----------------------
so I used sed to remove them by:
sed '/GATB/,/\-\-\-\-\-\-\-\-\-\-\-\-\-\-/d' < input > output
- Tags:
- sed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО04-02-2011 02:20 AM
тАО04-02-2011 02:20 AM
Re: Script to work on a large file
>sed '/GATB/,/\-\-\-\-\-\-\-\-\-\-\-\-\-\-/d' < input > output
You don't really need to escape a "-":
sed '/GATB/,/--------------/d' input > output
You don't really need to escape a "-":
sed '/GATB/,/--------------/d' input > output
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.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP