Transposition

Résolu
Bonjour,

Je souhaiterais transposer mes données présentes dans un fichier dans une seule colonne comme suit :

toto&tata&titi&tutu titi&tata
toto&tata&titi&tutu titi&tata

toto
tata
titi
tutu titi
tata
toto
tata
titi
tutu titi
tata

Les espaces entre tutu et titi sont voulus.

Merci.

4 réponses

  1. Merci zipe31 mais cela ne fonctionne pas chez moi :

    echo 'cat name' | awk 'BEGIN { RS="[]" }1' > name11
    awk: line 0 (NR=1): Record too long (LIMIT: 19999 bytes)

    -rw-rw---- 1 linus in 34916 Aug 3 12:25 name

    -rw-rw---- 1 linus in 0 Aug 3 20:57 name11

    Avec le fichier plop non plus :

    cat plop
    toto&tata#titi&tutu titi&tata
    toto#tata&titi&tutu titi&tata

    awk 'BEGIN { RS="[]" }1' plop
    toto&tata#titi&tutu titi&tata
    toto#tata&titi&tutu titi&tata

    sed 's/&\|#/\n/g' plop
    toto&tata#titi&tutu titi&tata
    toto#tata&titi&tutu titi&tata
    1. Contributeur
      Quel système d'exploitation ? Unix ? Linux ?
      Quelle version de awk et sed ?
      Quel format pour le fichier d'entrée ? Unix ? Dos ?
    2. SunOS ars103 5.10 Generic_127111-03 sun4v sparc SUNW,Sun-Fire-T200

      file /usr/bin/awk
      /usr/bin/awk: ELF 32-bit MSB executable SPARC Version 1, dynamically linked, stripped

      file /usr/bin/sed
      /usr/bin/sed: ELF 32-bit MSB executable SPARC Version 1, dynamically linked, stripped

      Fichier d'entrée : Unix
    3. Contributeur
      Essaye avec
      nawk
      à la place de awk.
    4. nok :

      nawk 'BEGIN { RS="[]" }1' plop
      toto&tata#titi&tutu titi&tata
      toto#tata&titi&tutu titi&tata
    5. Contributeur
      Je ne sais que dire...

      Essaye uniquement avec le "#" pour voir si ça passe...

      nawk 'BEGIN { RS="#" }1' plop 
  2. Contributeur
    Salut,

    $ cat plop 
    toto&tata#titi&tutu titi&tata
    toto#tata&titi&tutu titi&tata

    $ awk 'BEGIN { RS="[]" }1' plop
    toto
    tata
    titi
    tutu titi
    tata
    toto
    tata
    titi
    tutu titi
    tata

    $ sed 's/&\|#/\n/g' plop
    toto
    tata
    titi
    tutu titi
    tata
    toto
    tata
    titi
    tutu titi
    tata

    1. J'utilise la commande suivante :

      echo 'cat name4' | awk 'BEGIN { RS="&" }1' > name5

      Cela fonctionne quand je n'ai que des &

      J'aimerais la faire évoluer de manière à ce que le traitement s'effectue quand j'ai des & ou des #