Unix Shell - How to prevent screen print out

This is Interesting: Free IT Magazines  
Home > Archive > Unix Shell > February 2006 > How to prevent screen print out





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author How to prevent screen print out
linq936@hotmail.com

2006-02-26, 10:18 am

Hi,
I have this in my BASH script,

LIST=`echo $tmp_merge | sed -e "s/ /\n/g" | uniq | tr "\n" " "`

It works fine, but I see all the contents of $tmp_merge are print to
screen, this looks messy.

I wonder what is the way to prevent this?

Thanks.

Janis Papanagnou

2006-02-26, 10:18 am

linq936@hotmail.com wrote:
> Hi,
> I have this in my BASH script,
>
> LIST=`echo $tmp_merge | sed -e "s/ /\n/g" | uniq | tr "\n" " "`
>
> It works fine, but I see all the contents of $tmp_merge are print to
> screen, this looks messy.


Works fine for me. Could the problem be somewhere else in the script?

> I wonder what is the way to prevent this?


Provide some input/output data to better understand what's going on.

> Thanks.
>


Janis
Chris F.A. Johnson

2006-02-26, 10:18 am

On 2006-02-23, linq936@hotmail.com wrote:
> Hi,
> I have this in my BASH script,
>
> LIST=`echo $tmp_merge | sed -e "s/ /\n/g" | uniq | tr "\n" " "`


You don't need sed:

LIST=`set -f; printf "%s\n" $tmp_merge | uniq | tr "\n" " "`

And you do know that only adjacent identical lines will be
affected?

> It works fine, but I see all the contents of $tmp_merge are print to
> screen, this looks messy.
>
> I wonder what is the way to prevent this?


The output is not coming from that line. Check elsewhere in your
script.

--
Chris F.A. Johnson, author | <http://cfaj.freeshell.org>
Shell Scripting Recipes: | My code in this post, if any,
A Problem-Solution Approach | is released under the
2005, Apress | GNU General Public Licence
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com