Samit Kumar Patra
Samit Kumar Patra

Reputation: 31

Remove extra char in the string in shell script

line="premon D0000070 0x201 0x40"  # it has 26 chars
echo $line | wc -c # giving out put 27 chars.

i want to remove the extra char in the string.. please help?

Upvotes: 2

Views: 127

Answers (1)

banuj
banuj

Reputation: 3230

Actually you don't have an extra char in your string. echo puts a '\n' at the end of line. If you don't want to echo that char, you can do

 echo -n $line | wc -c

Upvotes: 4

Related Questions