shell-script-pt
[Top][All Lists]
Advanced

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

Re: [shell-script] Sed imprimir a segunda linha na frente da primeira


From: Raul Libório
Subject: Re: [shell-script] Sed imprimir a segunda linha na frente da primeira
Date: Fri, 21 Apr 2017 20:51:40 -0300

Ah, perdão... Não observei que você quer com os números pares na primeira coluna. Sorry! =\

Raul Libório
http://rauhmaru.blogspot.com/
openSUSE Member | Linux User #4444581

/etc/httpd/conf.d/ssl.conf:7
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.

2017-04-21 20:48 GMT-03:00 Raul Libório <address@hidden>:
Lembrando que o comando paste também faz isso aí

raul@finarfin:~> cat file
1
2
3
4
5
6
7
8
9
10
raul@finarfin:~> cat file | paste -d" " - -
1 2
3 4
5 6
7 8
9 10
raul@finarfin:~>

Raul Libório
http://rauhmaru.blogspot.com/
openSUSE Member | Linux User #4444581

/etc/httpd/conf.d/ssl.conf:7
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.

2017-04-21 19:47 GMT-03:00 Robson Alexandre address@hidden [shell-script] <address@hidden.br>:
 

Boa noite Tiago,

Só faltou vc usar a opção -n do sed e mandar imprimir (opção p) apenas a saída q deseja


$ seq 10 | sed -n 'h;n;G;s/\n/ /p'
2 1
4 3
6 5
8 7
10 9


Atenciosamente
Robson Alexandre

Em sex, 21 de abr de 2017 às 19:15, Tiago Tarifa address@hidden [shell-script] <address@hidden.br> escreveu:
 

Boa noite pessoal!
Acho que minha dúvida é simples, mas estou quebrando a cabeça...

Eu quero que o sed transforme isso:
1
2
3
4
5
6
7
8
9
10

em isso:
2 1
4 3
6 5
8 7
10 9

Eu não sei se o sed é o melhor cara para fazer isso, mas estou tentando com ele há algumas horas e não estou conseguindo... o máximo que consegui foi este comando:
seq 1 10 | sed -r 'h;n;G; s/\n/ /'


--
Atenciosamente

Robson Alexandre




reply via email to

[Prev in Thread] Current Thread [Next in Thread]