- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Basic Question on WC
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
08-21-2006 03:14 AM
08-21-2006 03:14 AM
6
Prompt>echo 'hello' | wc -m
6
Prompt>echo 'test' | wc -m
5
Prompt>echo test | wc -m
5
Prompt>echo test|wc -m
5
Prompt>echo test|wc -C
5
i'm expecting 5 characters for hello and 4 for test !!! what am i missing ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2006 03:17 AM
08-21-2006 03:17 AM
Re: Basic Question on WC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2006 03:18 AM
08-21-2006 03:18 AM
Re: Basic Question on WC
man wc
"A word is a string of characters delimited by spaces, tabs, or newlines."
It the newline char at the end:
echo hello | wc -l
1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2006 03:20 AM
08-21-2006 03:20 AM
Re: Basic Question on WC
The newline character is counted. You can see visually what Melvyn refers to by doing:
# echo hello|cat -etv
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2006 03:27 AM
08-21-2006 03:27 AM
Re: Basic Question on WC
expr length $(echo "hello")
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2006 03:39 AM
08-21-2006 03:39 AM
Solutionif you just need the length of a string:
a=hello
print ${#a}
No additional newline needs to be considered.
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2006 03:44 AM
08-21-2006 03:44 AM
Re: Basic Question on WC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2006 03:45 AM
08-21-2006 03:45 AM
Re: Basic Question on WC
fifejj:/> echo "test\c" | wc -m
4
fifejj:/> echo "hello\c" | wc -m
5
fifejj:/> mystring=hello
fifejj:/> echo "${mystring}\c" | wc -m
5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2006 03:50 AM
08-21-2006 03:50 AM
Re: Basic Question on WC
# echo hello | od -c
# echo test | od -c
cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-21-2006 03:53 AM
08-21-2006 03:53 AM
Re: Basic Question on WC
5