- #1
dRic2
Gold Member
- 890
- 225
I have a DATA.txt file which contains lots of useless info. I get the informations I want typing in my terminal
and the output is the following:
freq ( 1) = -0.193719 [THz] = -6.461768 [cm-1]
freq ( 2) = -0.193719 [THz] = -6.461768 [cm-1]
freq ( 3) = -0.193719 [THz] = -6.461768 [cm-1]
freq ( 4) = 5.968261 [THz] = 199.079745 [cm-1]
freq ( 5) = 5.968261 [THz] = 199.079745 [cm-1]
freq ( 6) = 5.968261 [THz] = 199.079745 [cm-1]
I would like to create a bash script which extracts only the numbers of the last column and stores them in a new .txt file as follows:
1 -6.461768
2 -6.461768
3 -6.461768
4 199.079745
5 199.079745
6 199.079745
I though of something on the line of
I don't really know how to program in bash... I just copy and modify scripts that were handed to me in similar occasions. But I don't know how to implement this one.
Thanks in advance!
Ric
Bash:
grep freq DATA.txt
freq ( 1) = -0.193719 [THz] = -6.461768 [cm-1]
freq ( 2) = -0.193719 [THz] = -6.461768 [cm-1]
freq ( 3) = -0.193719 [THz] = -6.461768 [cm-1]
freq ( 4) = 5.968261 [THz] = 199.079745 [cm-1]
freq ( 5) = 5.968261 [THz] = 199.079745 [cm-1]
freq ( 6) = 5.968261 [THz] = 199.079745 [cm-1]
I would like to create a bash script which extracts only the numbers of the last column and stores them in a new .txt file as follows:
1 -6.461768
2 -6.461768
3 -6.461768
4 199.079745
5 199.079745
6 199.079745
I though of something on the line of
Bash:
FILEIN=DATA.txt
FILEOUT=OUT.txt
while ...
freq = `grep freq $FILEIN | ... something ...`
echo ... ${freq} >> $FILEOUT
done
I don't really know how to program in bash... I just copy and modify scripts that were handed to me in similar occasions. But I don't know how to implement this one.
Thanks in advance!
Ric