- Community Home
- >
- Servers and Operating Systems
- >
- Operating System - HP-UX
- >
- General
- >
- tr and :print option
-
- Forums
-
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
- HPE Blog, Austria, Germany & Switzerland
- Blog HPE, France
- HPE Blog, Italy
- HPE Blog, Japan
- HPE Blog, Middle East
- HPE Blog, Russia
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
-
Blogs
- Advancing Life & Work
- Advantage EX
- Alliances
- Around the Storage Block
- HPE Blog, Latin America
- HPE Blog, Middle East
- HPE Blog, Saudi Arabia
- HPE Blog, South Africa
- HPE Blog, UK & Ireland
- HPE Ezmeral: Uncut
- OEM Solutions
- Servers & Systems: The Right Compute
- Tech Insights
- The Cloud Experience Everywhere
-
Information
- Community
- Welcome
- Getting Started
- FAQ
- Ranking Overview
- Rules of Participation
- Tips and Tricks
- Resources
- Announcements
- Email us
- Feedback
- Information Libraries
- Integrated Systems
- Networking
- Servers
- Storage
- Other HPE Sites
- Support Center
- Aruba Airheads Community
- Enterprise.nxt
- HPE Dev Community
- Cloud28+ Community
- Marketplace
-
Forums
-
Blogs
-
Information
-
English
- 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
- Email to a Friend
- Report Inappropriate Content
11-15-2005 08:28 AM
11-15-2005 08:28 AM
tr -d [^:print]
Seems to make sense to me; delete all characters that are not in the printable class.
(There is no specific info in the man page for tr about :print, but this seems to be what it says).
When I run the following data through the command:
man tr
vi find_new_histfile_lines
cd /admin/scripts/
vi find_new_histfile_lines
sh -x find_new_histfile_lines
I get the following output:
ma
v fd_ew_hsfle_les
cd /adm/scs/
v fd_ew_hsfle_les
sh -x fd_ew_hsfle_les
Does this make any sense at all? It seems like certain characters (e.g., "n", "t") are being treated as unprintable.
Scott
Solved! Go to Solution.
- Tags:
- tr
- unprintable chars
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-15-2005 09:33 AM
11-15-2005 09:33 AM
Re: tr and :print option
tr -d [:graph:]
"graph" is non-printable characters. Also in your sample you were missing a colon. The class would be [:print:].
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-15-2005 09:34 AM
11-15-2005 09:34 AM
Re: tr and :print option
I would do it like this: Note that printables include ' ' through '~' (octal 040 - 176) and you probably don't want to throw away LF's (octal 012) as well. Not that the 'c' tr option complements the string so we don't need no stinkin' '^'.
cat myfile | tr -cd "[\040-\176][\012]" > newfile
If your want to keep formfeeds and CR's as well the append their octal equivalents to the string as well (inside brackets).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-15-2005 09:43 AM
11-15-2005 09:43 AM
Re: tr and :print option
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-15-2005 09:43 AM
11-15-2005 09:43 AM
Re: tr and :print option
I was basing this on another post and what I see in the man page for "tr":
[:class:]or [[:class:]] Stands for all the characters belonging to the
defined character class, as defined by the current
setting of LC_CTYPE locale category. The following
character class names will be accepted when
specified in string1: alnum, alpha, blank, cntrl.
digit, graph, lower, print, punct, space, upper,
or xdigit
I have tried with and without the "^", and with "[" and "[[". So while I understand it seems to be omitting these characters, I wonder how I can make the class of ":print" work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-15-2005 09:46 AM
11-15-2005 09:46 AM
Re: tr and :print option
tr -d [:print:]
and this:
tr -d [^:print:]
The first gives me the same results, the second gives me all blanks.
Scott
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-15-2005 10:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-16-2005 01:51 AM
11-16-2005 01:51 AM
Re: tr and :print option
I was origianlly using strings, but I saw that one character commands (like "w") were being stripped out by strings. So that's why I'm looking at tr.
Scott
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-16-2005 02:03 AM
11-16-2005 02:03 AM
Re: tr and :print option
cat myfile | tr -Acs "[[:print:]][\012]" > newfile
should, of course be:
cat myfile | tr -Acd "[[:print:]][\012]" > newfile
Hewlett Packard Enterprise International
- Communities
- HPE Blogs and Forum
© Copyright 2021 Hewlett Packard Enterprise Development LP