🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.unix.shell
2 messages
2 total messages Started by Dave Taylor {guest} Tue, 09 Oct 1990 16:55
Counting characters in a string...bourne
#1444
Author: Dave Taylor {guest}
Date: Tue, 09 Oct 1990 16:55
46 lines
1831 bytes
First off:

I am trying to count the number of characters in a string, but I seem to
be running into problems.  I tried:
	echo $STRING | wc | awk '{ print $3 }'
the only problem with this is that it drops spaces.  I want to count ALL
the characters.  I suppose I could just adapt some of the awk scripts that
have been flying on the newsgroups lately, but I was looking for something
clean and simple.

Secondly:

WHY -- WHY -- WHY -- WHY -- WHY -- WHY -- WHY -- WHY -- WHY -- WHY -- WHY ??

Why does the following string get pushed together??

Script:
TITLE="This              is some text"
echo "$TITLE"

Output:
This is some text

How to I keep it from being pushed together??


THIRDLY:

The point of all this is to be able to center a header with pwd in it.  So that
is says something like:

program 1.1			Check to see foo.bar			/u/user

I need to count the spaces between bar and EOL as well as the length of the pwd
string.  A while loop using expr to count takes an eternity.  What could make
it faster???

Thanks in advance,


--david
-- 
-------                                                                 -------
David E. Taylor, OMSS UNIX Development // Operation Mobilization USA
AT&T: (404) 631-0432  +====+  UUCP:    {decvax, sun!sunatl, gatech}!emory!om!dt
FAX:  (404) 631-0439  +====+  Internet: dt%om.uucp@mathcs.emory.edu
Re: Counting characters in a string...bourne
#1468
Author: Paul S. Sawyer
Date: Sat, 13 Oct 1990 19:26
16 lines
1135 bytes
In article <1990Oct10.212943.9227@iwarp.intel.com> merlyn@iwarp.intel.com (Randal Schwartz) writes:
>
>Overkill.  Let nroff do it.

But AT&T has determined that nroff is too powerful a tool to include with
System V (V.2, anyway...)  (Documenter's Workbench optional at extra cost...)

>Or, in Perl:

OK.  The price is right, anyway.  (Then there's always AWF!  B-)


-- 
Paul S. Sawyer              uunet!unh!unhtel!paul     paul@unhtel.UUCP
UNH Telecommunications        attmail!psawyer       p_sawyer@UNHH.BITNET
Durham, NH  03824-3523      VOX: +1 603 862 3262    FAX: +1 603 862 2030
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads