wc -c (number of characters)


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers wc -c (number of characters)
# 1  
Old 02-08-2008
wc -c (number of characters)

for some reason word count always counts one extra character.
for example,
echo 11 | wc -c
counts 3 characters instead of 2
anyone know how to get the exact number of characters?
# 2  
Old 02-08-2008
Quote:
Originally Posted by metalwarrior
for some reason word count always counts one extra character.
for example,
echo 11 | wc -c
counts 3 characters instead of 2
anyone know how to get the exact number of characters?
There is also the newline character which you dont see.

Code:
[/tmp]$ echo "11" | od -a
0000000   1   1  nl
0000003
[/tmp]$ echo -n "11" | od -a
0000000   1   1
0000002
[/tmp]$ echo -n "11" | wc -c
2

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to count number of characters of wc -l output?

I want count number of characters / find the length of the 'wc -l' output This is the command bash-3.2$ gzcat /home/sid/file1.dat |wc -l 830752 So final out I want is 6 i.e lenght of 830752 I tried with awk bash-3.2$ gzcat /home/sid/file1.dat |wc -l | awk '{print length ($0)... (3 Replies)
Discussion started by: sidnow
3 Replies

2. Shell Programming and Scripting

How to truncate a string to x number characters?

Hello: I have a large file which contains lines like the following: 1/t123ab, &Xx:1:1234:12345:123456@ABCDEFG... at -$100.00% /t is a tab, spaces are as indicated the string "&Xx:1:1234:12345:123456$ABCDEFG..." has a slightly variable number of numbers and letters, but it always starts... (9 Replies)
Discussion started by: Tectona
9 Replies

3. Shell Programming and Scripting

Counting the number of characters

Hi all, Can someone help me in getting the following o/p I/p:... (7 Replies)
Discussion started by: Sri3001
7 Replies

4. Shell Programming and Scripting

Count number of characters in particular column

Hi i have data like abchd 124 ldskc aattggcc each separated by tab space i want to count number of characters in 4th column and print it in new column with tabspace for every line can anyone help me how to do it. Thanks. (3 Replies)
Discussion started by: bhargavpbk88
3 Replies

5. UNIX for Dummies Questions & Answers

AWK - number of specified characters in a string

Hello, I'm new to using AWK and would be grateful for some basic advice to get me started. I have a file consisting of 10 fields. Initially I wish to calculate the number of . , ~ and ^ characters in the 9th field ($9) of each line. This particular string also contains alphabetical... (6 Replies)
Discussion started by: Olly
6 Replies

6. UNIX for Dummies Questions & Answers

reducing the number of characters in a column

Hi, I would like to take the first column of a bunch of lines and take only the 6th through 15th characters. The first column are not regular. gbAY277147.1Ptv3.T1469 CTTGAACAT gbAY277149.1Ptro3.T1469 CTTGAACAT gbAY287891.1Hs3.T1469 CTTGAACATTTGC into 7147.1Ptv3 CTTGAACAT... (4 Replies)
Discussion started by: mikey11415
4 Replies

7. Shell Programming and Scripting

number of characters in a string

Hi there, I have some user input in a variable called $VAR, and i need to ensure that the string is 5 or less characters .... does anybody know how i can count the characters in the variables ? any help would be great, cheers (2 Replies)
Discussion started by: rethink
2 Replies

8. Shell Programming and Scripting

Maximum number of characters in a line.

Hi, Could any one please let me know what is the maximum number of characters that will fit into a single line of a flat file on a unix. Thanks. (1 Reply)
Discussion started by: Shivdatta
1 Replies

9. Shell Programming and Scripting

split based on the number of characters

Hello, if i have file like this: 010000890306932455804 05306977653873 0520080417010520ISMS SMT ZZZZZZZZZZZZZOC30693599000 30971360000 ZZZZZZZZZZZZZZZZZZZZ202011302942311 010000890306946317387 05306977313623 0520080417010520ISMS SMT... (6 Replies)
Discussion started by: chriss_58
6 Replies

10. Shell Programming and Scripting

number of escape characters?

Hi, I am trying to execute the following command from a batch script, but no matter how many escape characters I put in it doesn't execute properly. It works fine from the command line with quotes around the -exec part. #!/bin/sh /usr/local/bin/sudo /usr/atria/bin/cleartool setview -exec... (0 Replies)
Discussion started by: Sebarry
0 Replies
Login or Register to Ask a Question