Simpler Navigation for Servers and Operating Systems - Please Update Your Bookmarks
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
If you have bookmarked forums or discussion boards in Servers and Operating Systems, we suggest you check and update them as needed.
cancel
Showing results for 
Search instead for 
Did you mean: 

Shell Scripting

Ankush_me
Occasional Visitor

Shell Scripting

Can u all help me in devloping a shell script which converts the string into paragrah detecting tab spaces and new line and commas also.i m not getting how to procced.
5 REPLIES
Steven E. Protter
Exalted Contributor

Re: Shell Scripting

Shalom,

http://www.freeos.com/guides/lsst/

I generally don't write complex shell scripts for points. Shell scripting to some degree is an important part of systems administration.

Time to learn.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Ankush_me
Occasional Visitor

Re: Shell Scripting

Hi Every one

But by means of this link i didnt get a much idea to procced.

Can some one help me in that?
Andrew Cowan
Honored Contributor

Re: Shell Scripting

Ankush,

Can you be more clear as what is in the string, and what you mean by a paragraph as this is normally decided by a carriage-return at the end of your text. Eg. I typed this message as one continoue line and the web-form in the form decides how to wrap it around?
James R. Ferguson
Acclaimed Contributor

Re: Shell Scripting

Hi:

If you will accept Perl instead of a shell script, consider this:

Consider this:

/*file_begins*/

Perl has a read-made soultion for you if you are willing to use it instead of a pure shell script. The Perl module you need is called Text::Wrap and it's included in you standard Perl distribution. In fact, you can use this very file to call it and show it reformatting. Let's reformat this into text that spans no more than 30-columns
and has it paragraphs indented four (4) spaces.

/*file_ends*/

Now, use this passing the name of the file with the above contents:

# perl -MText::Wrap -e '@lines=<>;$Text::Wrap::columns=30;print wrap(" ","",@lines)' file

Perl has a read-made
soultion for you if you are
willing to use it
instead of a pure shell
script. The Perl module you
need is called
Text::Wrap and it's included
in you standard Perl
distribution. In fact,
you can use this very file to
call it and show it
reformatting. Let's
reformat this into text that
spans no more than 30-columns
and has it paragraphs
indented four (4) spaces.

Regards!

...JRF...
Stuart Browne
Honored Contributor

Re: Shell Scripting

'pr' is your friend.

It's a print formatter. Tell it how wide you want to go, how long your pages are, and it does the rest for you.
One long-haired git at your service...