HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How to replace a non-printable characters?
Operating System - HP-UX
1826598
Members
3513
Online
109695
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
04-17-2000 05:08 PM
04-17-2000 05:08 PM
How to replace a non-printable characters?
My question is how to substitue a non-printable character into a return
character "\n" using sed?
The following command seems doesn't work.
#top -d 1 >f1
1#sed "1,$ s/\033/\012/g" f1
Why? Here \033 stands for ASCII code 033 which displays as ^[
(non-printable), \012 is "carriage return".
Another question is how to count the number of appearances of a particular
string in a file? grep -c can only find the number of lines that contain the
string.
character "\n" using sed?
The following command seems doesn't work.
#top -d 1 >f1
1#sed "1,$ s/\033/\012/g" f1
Why? Here \033 stands for ASCII code 033 which displays as ^[
(non-printable), \012 is "carriage return".
Another question is how to count the number of appearances of a particular
string in a file? grep -c can only find the number of lines that contain the
string.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2000 10:45 PM
04-18-2000 10:45 PM
Re: How to replace a non-printable characters?
Your top question has been answered on the other message thread. This message
is in response to your question "how to count the number of appearances of a
particular string in a file?"
Use the command 'wc'. 'wc -l' will count the number of lines it appears on;
'wc -w' will count the number of words. For more information, see the man page
for wc(1).
For example:
# grep abcd testfile |wc -l
where abcd is the string I am looking for
testfile is the filename
The results will look like the following:
# grep abcd testfile |wc -l
6
The same 'wc -l' executed on the file, will show the total lines within the
file.
# wc -l testfile
21
is in response to your question "how to count the number of appearances of a
particular string in a file?"
Use the command 'wc'. 'wc -l' will count the number of lines it appears on;
'wc -w' will count the number of words. For more information, see the man page
for wc(1).
For example:
# grep abcd testfile |wc -l
where abcd is the string I am looking for
testfile is the filename
The results will look like the following:
# grep abcd testfile |wc -l
6
The same 'wc -l' executed on the file, will show the total lines within the
file.
# wc -l testfile
21
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-19-2000 04:30 PM
04-19-2000 04:30 PM
Re: How to replace a non-printable characters?
But if one line contains two "abcd", then your calculation is wrong, right? I
don't want to calculate
the total number of words or lines, I only want to
find out the number of occurrence of certain string.
Not to mention "top", how can I replace a non-printable character such as
\0344 with \012 if it is followed by another string "]B" ?
don't want to calculate
the total number of words or lines, I only want to
find out the number of occurrence of certain string.
Not to mention "top", how can I replace a non-printable character such as
\0344 with \012 if it is followed by another string "]B" ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2000 12:14 PM
04-20-2000 12:14 PM
Re: How to replace a non-printable characters?
Use a for and case combinations.
The following gives you the idea. Syntax is to be built.
j=0
for i in `cat yourfilename`
do
case $i=yourstring) j=j+1;;
case *) NOOP ;; # you can put a favourite no operation
esac
done
echo $j
This works on most of text files
The following gives you the idea. Syntax is to be built.
j=0
for i in `cat yourfilename`
do
case $i=yourstring) j=j+1;;
case *) NOOP ;; # you can put a favourite no operation
esac
done
echo $j
This works on most of text files
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