1753454 Members
6088 Online
108794 Solutions
New Discussion юеВ

Shell Scripting

 
Ankush_me
New Member

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 5
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
New Member

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...