- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- awk - searching/replacing control characters
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
12-02-2002 02:52 AM
12-02-2002 02:52 AM
awk - searching/replacing control characters
I am trying to delete a load of control characters from a file that has acquired a load of new text via conversion problems. I.e. the pipe delimitted file looks like :
aaaa|bbbb|cccc^M
dddd|eeee|ffff^M
gggg|hhhh|iiii^M
what I am trying to do is convert it to
aaaa|bbbb|cccc|eor
dddd|eeee|ffff|eor
gggg|hhhh|iiii|eor
I have tried the following :
cat filename | awk -F"|" '
{printf("%s|%s|%s|eor",$1,$2,$3)}'
but this gives :
aaaa|bbbb|cccc^M|eor
dddd|eeee|ffff^M|eor
gggg|hhhh|iiii^M|eor
With my limited knowledge of awk, could someone suggest a script that would do this, or better still, identify how awk (if it can that is), searches for this type of character (^M indicates a newline I think)
thanks to you all!
John
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2002 02:59 AM
12-02-2002 02:59 AM
Re: awk - searching/replacing control characters
cat test | awk -F"|" {printf("%s|%s|eor\n",$1,$2,$3)}'
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2002 03:04 AM
12-02-2002 03:04 AM
Re: awk - searching/replacing control characters
cat
This will replace any character followed by the end of line marker ($) with |eor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2002 03:05 AM
12-02-2002 03:05 AM
Re: awk - searching/replacing control characters
You should perhaps try to delete these ^m before reformatting using either sed ot dos2ux.
dos2ux filename | awk '{printf "%s|eor\", $0)}
or the most simple :
sed 's/^\(.*\)^M/&|eor/' filename
use ^V^M to avoid ^M interpretation.
Regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2002 03:07 AM
12-02-2002 03:07 AM
Re: awk - searching/replacing control characters
I missed the \n in my previous response!
I have been using :
cat filename | awk -F"|" '
{printf("%s|%s|%s|eor\n",$1,$2,$3)}'
The awk script you mentioned, I think would miss out a column I need (cccc - eeee and iiii)
thanks
John
P.s. I don't know why, but I have just logged in as myself, and got logged in as some person called Lemaitre!
whats going on?????
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2002 03:07 AM
12-02-2002 03:07 AM
Re: awk - searching/replacing control characters
Clever '.$' :^) , not to deal with ^M interpretation. I like it !
Jean-Louis.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2002 03:08 AM
12-02-2002 03:08 AM
Re: awk - searching/replacing control characters
in addition to the fact that I have somehow logged in as another person (le-maitre).... I CANT assign points!!!
NOOOO!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2002 03:44 AM
12-02-2002 03:44 AM
Re: awk - searching/replacing control characters
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2002 04:32 AM
12-02-2002 04:32 AM
Re: awk - searching/replacing control characters
If you didn't ftp the file then just follow the suggestions above.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2002 06:08 AM
12-02-2002 06:08 AM
Re: awk - searching/replacing control characters
only an additional info:
this ^M is the UX-interpretation of a DOS carrige return.
To eliminate this character you only need a dos2ux!
dos2ux file>file2
and the ^M will disappear!
Regards
Volkmar