I have three columns of data in one file, i.e.
0.464980006 0.237939999 0.000000000
0.464980006 0.737940013 0.000000000
0.964980006 0.237939999 0.000000000
0.964980006 0.737940013 0.000000000
0.298310012 0.404610008 0.068700001
0.298310012 0.904609978 0.068700001
0.798309982 0.404610008 0.068700001
0.798309982 0.904609978 0.068700001
Now I want to append F F F to the end of each line, how should I achieve it?
Here is my code:
#!/bin/bash
tail -n +9 POSCAR | head -n 24 | sort -k3 | head -8 > o-bot-layer
tail -n +9 POSCAR | head -n 24 | sort -k3 | tail -16 > o-sur-layer
tail -n +33 POSCAR | sort -k3 | head -4 > ce-bot-layer
tail -n +33 POSCAR | sort -k3 | tail -8 > ce-sur-layer
cat o-bot-layer | awk '{print $1,$2,$3,"F F F"}' > o-bot-layer
head -n 8 POSCAR > lat
cat o-sur-layer >> lat
cat o-bot-layer >> lat
cat ce-sur-layer >> lat
cat ce-bot-layer >> lat
mv lat pos.str
rm o-sur-layer o-bot-layer ce-sur-layer ce-bot-layer
It doesn't work. I tried sed 's/$' and awk '{print $0, ""}' in other people's post, the weird thing is I only get it append to the beginning of the line, not the end.
Something like this:
F F F0002 0.571280003 0.137400001
F F F0017 0.071280003 0.137400001
F F F0017 0.571280003 0.137400001
F F F0006 0.237939999 0.206110001
F F F0006 0.737940013 0.206110001
F F F0006 0.237939999 0.206110001
F F F0006 0.737940013 0.206110001
F F F0012 0.404610008 0.274809986
F F F0012 0.904609978 0.274809986
F F F9982 0.404610008 0.274809986
F F F9982 0.904609978 0.274809986
F F F0002 0.071280003 0.343510002
F F F0002 0.571280003 0.343510002
F F F0017 0.071280003 0.343510002
F F F0017 0.571280003 0.343510002
F F F0006 0.237939999 0.000000000
F F F0006 0.737940013 0.000000000
F F F0006 0.237939999 0.000000000
F F F0006 0.737940013 0.000000000
F F F0012 0.404610008 0.068700001
F F F0012 0.904609978 0.068700001
F F F9982 0.404610008 0.068700001
F F F9982 0.904609978 0.068700001
F F F0012 0.404610008 0.171749994
F F F0012 0.904609978 0.171749994
F F F9982 0.404610008 0.171749994
I suspect there are some hidden thing in my file format, something like \n at the beginning of each line so sed $s would think the beginning of line is the end of line. I am not sure...
Thank you!