Re: Bash --- columns problem ??

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux