Jump to content
Fórum Script Brasil
  • 0

Problemas com o awk no Ubuntu 20.04


Rls
 Share

Question

Prezados, bom dia.
Utilizo o script abaixo para somar valores dispostos em uma mesma linha de diferentes colunas.
##########################################################################
#!/bin/bash

## Parametros a definir ####
tam=3 #número de colunas
############################

touch tmp
for i in *PDOS*
do
awk '{print $2}' $i > col-$i.dat2
paste tmp col-$i.dat2 > total.dat
cp total.dat tmp
rm *.dat2
done
rm tmp
awk '{x=0; i=1; do {x=x+$i; i++} while(i<=3); print x}' total.dat> TESTE_SOMA.dat
awk '{print $1}' *#1\(Cd\)_wfc#1\(s\)> energia.dat
paste energia.dat TESTE_SOMA.dat> TESTE_SOMA_FINAL.dat
##########################################################################
Uma amostra do conteúdo do arquivo designado por total.dat é a que se segue:
##########################################################################
E E E
0.667E-06 0.669E-07 0.578E-08
0.732E-06 0.738E-07 0.637E-08
0.804E-06 0.814E-07 0.703E-08
0.882E-06 0.896E-07 0.775E-08
0.968E-06 0.987E-07 0.854E-08
0.106E-05 0.109E-06 0.940E-08
0.116E-05 0.120E-06 0.104E-07
0.127E-05 0.132E-06 0.114E-07
0.140E-05 0.145E-06 0.125E-07
0.153E-05 0.159E-06 0.138E-07
0.167E-05 0.175E-06 0.152E-07
0.183E-05 0.192E-06 0.167E-07

##########################################################################
Para citar um exemplo: se meu arquivo tem 3 colunas e 5000 linhas, em cada uma delas somo o primeiro valor da primeira coluna com o primeiro valor da segunda coluna e o primeiro valor da terceira coluna. O procedimento é realizado para cada uma das linhas. Utilizo awk para realizar as tarefas. Este script sempre funcionou sem nenhum problema. Entretanto, na semana passada instalei o Ubuntu 20.04 no meu computador e o script parou de funcionar: a coluna da soma está sempre preenchida com zeros nos arquivos TESTE_SOMA.dat ou TESTE_SOMA_FINAL.dat. Minha esperança é que algum membro da comunidade consiga me ajudar com este problema. Agradeço a todos pela atenção.

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Forum Statistics

    • Total Topics
      149.6k
    • Total Posts
      646.2k
×
×
  • Create New...