FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Fedora User

 
 
LinkBack Thread Tools
 
Old 12-15-2007, 10:07 AM
"G.Wolfe Woodbury"
 
Default Bash --- columns problem ??

On Sat, Dec 15, 2007 at 05:52:25AM -0500, William Case wrote:
> Hi;
>
> I am having a bit of a brain cramp.
>
> I have a text file with 1100 one word lines in it. I would like to
> transpose that file into a three column text file reducing it from 23
> pages to 8 pages before printing. I did something similar from the
> command line over a year ago, but for the life of me I can't remember
> how. I do remember that it was simple at the time.
>
> I have tried every possible combination I can think of with grep |
> column.
>
> If this problem is familiar to someone could they just point me; tickle
> my memory?

There are some options to the pr(1) command that will multi-column on the way to
printing.

--
Wolfe

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 12-15-2007, 01:48 PM
"Jacques B."
 
Default Bash --- columns problem ??

On Dec 15, 2007 6:07 AM, G.Wolfe Woodbury <ggw@wolves.durham.nc.us> wrote:
> On Sat, Dec 15, 2007 at 05:52:25AM -0500, William Case wrote:
> > Hi;
> >
> > I am having a bit of a brain cramp.
> >
> > I have a text file with 1100 one word lines in it. I would like to
> > transpose that file into a three column text file reducing it from 23
> > pages to 8 pages before printing. I did something similar from the
> > command line over a year ago, but for the life of me I can't remember
> > how. I do remember that it was simple at the time.
> >
> > I have tried every possible combination I can think of with grep |
> > column.
> >
> > If this problem is familiar to someone could they just point me; tickle
> > my memory?
>
> There are some options to the pr(1) command that will multi-column on the way to
> printing.
>
> --
> Wolfe
>
In absence of that doing it, another option that comes to mind is a
simple for loop (looping to 3) that removes CR/LF (or is it just LF?)
and dumps that loop to the printer or a new file. Put that loop
inside a larger for loop (for lines in ($cat {data_file}) do...). I'd
have to take time to play around with it to get the exact syntax but
you get the general idea. Or a sed command to remove all of the end
of lines (LF or CR/LF) such as "s/[1215]/ /g" to replace CR/LF
with a space instead to get a space delimited list of words and then
process it through pr if it doesn't work with the LF.

But the pr option suggested seems to be a valid option. Check out
http://linux.about.com/library/cmd/blcmdl1_pr.htm (or man pr of
course).

Jacques B

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 12-15-2007, 01:56 PM
"Robert P. J. Day"
 
Default Bash --- columns problem ??

On Sat, 15 Dec 2007, G.Wolfe Woodbury wrote:

> On Sat, Dec 15, 2007 at 05:52:25AM -0500, William Case wrote:
> > Hi;
> >
> > I am having a bit of a brain cramp.
> >
> > I have a text file with 1100 one word lines in it. I would like to
> > transpose that file into a three column text file reducing it from 23
> > pages to 8 pages before printing. I did something similar from the
> > command line over a year ago, but for the life of me I can't remember
> > how. I do remember that it was simple at the time.
> >
> > I have tried every possible combination I can think of with grep |
> > column.
> >
> > If this problem is familiar to someone could they just point me; tickle
> > my memory?
>
> There are some options to the pr(1) command that will multi-column on the way to
> printing.

$ pr --columns=3 -t <file>

i think.

rday
--
================================================== ======================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://crashcourse.ca
================================================== ======================

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 12-15-2007, 05:46 PM
William Case
 
Default Bash --- columns problem ??

Thanks Robert, Jacques and Wolfe

On Sat, 2007-12-15 at 09:56 -0500, Robert P. J. Day wrote:
> pr --columns=3 -t

Worked like a charm.

--
Regards Bill

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 12-16-2007, 02:36 AM
"Steven W. Orr"
 
Default Bash --- columns problem ??

On Saturday, Dec 15th 2007 at 05:52 -0000, quoth William Case:

=>Hi;
=>
=>I am having a bit of a brain cramp.
=>
=>I have a text file with 1100 one word lines in it. I would like to
=>transpose that file into a three column text file reducing it from 23
=>pages to 8 pages before printing. I did something similar from the
=>command line over a year ago, but for the life of me I can't remember
=>how. I do remember that it was simple at the time.
=>
=>I have tried every possible combination I can think of with grep |
=>column.
=>
=>If this problem is familiar to someone could they just point me; tickle
=>my memory?

Why use grep or pr or any other shellout when you can just do it right
from within bash?

myRead()
{
typeset line1, line2, line3
read line1
read line2
read line3
echo "$line1 $line2 $line3"
[[ -n "$line1" && -n "$line2" && -n "$line3" ]]
}
while myRead
do
:
done < /usr/share/dict/words

--
Time flies like the wind. Fruit flies like a banana. Stranger things have .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 
Old 12-16-2007, 04:04 AM
"Dean S. Messing"
 
Default Bash --- columns problem ??

Steven W. Orr wrote:
<snip>
: Why use grep or pr or any other shellout when you can just do it right
: from within bash?
:
: myRead()
: {
: typeset line1, line2, line3
: read line1
: read line2
: read line3
: echo "$line1 $line2 $line3"
: [[ -n "$line1" && -n "$line2" && -n "$line3" ]]
: }
: while myRead
: do
: :
: done < /usr/share/dict/words


I could be wrong, but to answer your question:

1) Because `pr --columns=3' is a whole lot easier to type than what you suggest

2) Because what you suggest has a bug, at least on my machine.
When I run it, I get


==>./foo
./foo: line 3: typeset: `line1,': not a valid identifier
./foo: line 3: typeset: `line2,': not a valid identifier
./foo: line 3: typeset: `line1,': not a valid identifier
./foo: line 3: typeset: `line2,': not a valid identifier
./foo: line 3: typeset: `line1,': not a valid identifier
./foo: line 3: typeset: `line2,': not a valid identifier
./foo: line 3: typeset: `line1,': not a valid identifier

and so forth


3) Because your suggestion would give the opposite of what I would
expect if I were asked to turn the following into three columns:

a
b
c
d
e
f
g
h
i
j
k
l

I would want:

a e i
b f j
c g k
d h l

Yours will give:

a b c
d e f
g h i
j k l

Dean

--
fedora-list mailing list
fedora-list@redhat.com
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
 

Thread Tools




All times are GMT. The time now is 12:18 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org