- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- sed or awk challenge
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
Forums
Discussions
Discussions
Discussions
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
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
11-14-2001 03:44 AM
11-14-2001 03:44 AM
sed or awk challenge
I have the following 'challenge':
- a 3rd party program reads the data in an ascii file until it finds a trailer record with the last word being "EOF".
- the program doesnot accept any characters or lines after this "EOF" marker. So the string EOF has to be followed by the actual EOF-code.
- The data for this file is spooled by the oracle utl_file package, so every written line in a text file is terminated with a line-feed/cariage return character.
- My question: does any one have a clue on how to replace the "EOF" string with the "EOF"string combined with the EOF character??
thanx in advance...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2001 03:51 AM
11-14-2001 03:51 AM
Re: sed or awk challenge
So if your file, /tmp/abc, contains:
this is a line
so is this
and this
this is the end EOF
should not get here
or here
is this what you require?:
awk '/EOF/{print;exit}{print}' /tmp/abc
this is a line
so is this
and this
this is the end EOF
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2001 03:55 AM
11-14-2001 03:55 AM
Re: sed or awk challenge
you da man Robin!!
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2001 03:59 AM
11-14-2001 03:59 AM
Re: sed or awk challenge
but if I transfer the file (binary or ascii) doesn't matter to a NT environment, there is still a new-line char after the EOF statement...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2001 04:05 AM
11-14-2001 04:05 AM
Re: sed or awk challenge
sorry, try this:
awk '/EOF/{printf"%s",$0;exit}{print}' /tmp/abc
Rgds, Robin.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2001 08:51 AM
11-14-2001 08:51 AM
Re: sed or awk challenge
I'd suggest just a small change on Robin's solution.
If you feed something like:
this is a line
so is this
and this
this is a false EOF folks...
this is the end EOF
should not get here
to the previous script, it will fail (EOF is there, but it is not the last word). A solution would be:
awk '/EOF[ \t]*$/{printf"%s",$0;exit}{print}'
Hope it helps,
Paga
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2001 10:16 AM
11-15-2001 10:16 AM
Re: sed or awk challenge
If you use vi to look at the file you see a ^M at the end of everyline. You can strip the control M on the Unix box if it came from NT.
However, I think you will have to have some kind of utility on the NT box that will give you an Unix shell to stripe the control M.
on the Unix side you can do something like
cat filename | sed 's/^M///g' > newfilename
the ^ is actually the control character not just a shift 6 you need to hit the control key.
Let me know if this is what you are asking?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-16-2001 12:29 AM
11-16-2001 12:29 AM
Re: sed or awk challenge
Marco's solution seems to do the trick after all. I MUST transfer the file binary though!
regards,
Rene