|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hello
I am searching something like the opposite of paste. I know that cut is somehow the opposite. But say I have $ cat myfile a d g b e h c f i and what I want to get out of the file myfile is this a b c d e f g h i That is put all columns after each other. I really don't see how I can achieve that with cut. I can think of $ cut -f 1,2,3 -d \ myfile --output-delimiter $'\n' a d g b e h c f i But that gives not the result I am searching for. Any ideas? Greetings Flo |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On 11/13/2007 11:46 AM, Florian Kaufmann wrote: > Hello > > I am searching something like the opposite of paste. I know that cut > is somehow the opposite. But say I have > > $ cat myfile > a d g > b e h > c f i > > and what I want to get out of the file myfile is this > a > b > c > d > e > f > g > h > i > > That is put all columns after each other. <snip> Try this: awk '{ for (fld=1;fld<=NF;fld++) a[NR,fld] = $fld } END{ for (fld=1;fld<=NF;fld++) for (rec=1;rec<=NR;rec++) print a[rec,fld] }' file Regards, Ed. |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On 2007-11-13, Florian Kaufmann <sensorflo@gmail.com> wrote:
> Hello > > I am searching something like the opposite of paste. I know that cut > is somehow the opposite. But say I have > > $ cat myfile > a d g > b e h > c f i > > and what I want to get out of the file myfile is this > a > b > c > d > e > f > g > h > i Maybe? for i in 1 2 3; do cut -d\ -f $i myfile ; done Best Regards, Claudio. |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
Florian Kaufmann wrote:
> > I am searching something like the opposite of paste. I know that cut > is somehow the opposite. But say I have > > $ cat myfile > a d g > b e h > c f i > > and what I want to get out of the file myfile is this > a > b > c > d > e > f > g > h > i $ echo "a d g b e h c f i" | perl -lane'push@{$x[$_]},shift@F for 0..$#F}{print for map@$_,@x' a b c d e f g h i John -- use Perl; program fulfillment |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
Florian Kaufmann <sensor...@gmail.com> wrote:
> Any ideas? It looks like -- and you do not make clear -- that you are _either_ doing a sort: sed -e 's/ /\ /g' myfile | sort # YASS: Yet Another Sed(1) Solution .... or an idempotent decomposition of the transpose of the matrix (laying the matrix on its side and enumerating the elements) -- which is Ed Morton's awk(1) solution. =Brian |
|
![]() |
| Outils de la discussion | |
|
|