help parsing file in bash
I need help parsing a file with awk and sed.
I have a program that outputs to a file in the following format 2013/12/09 00:22:16 Temperature 76.10F 2013/12/09 00:22:17 Temperature 76.10F I can use awk to clean this up a bit with the following command awk '{print $1, $2, $4}' temp.txt >fixedtemp.txt This is the output 2013/12/09 00:22:17 76.10F 2013/12/09 00:22:17 76.10F 2013/12/09 00:22:18 75.99F I am planning to import this into a spreadsheet but I want to remove the F at the end of each line. How can I accomplish that? Thanks. |
Substr? Like in
Code:
awk '{print $1, $2, substr($4,1,5)}' |
Or gensub ? - removes the requirement on knowing the length of the (sub-)string in advance
Code:
awk '{print $1, $2, gensub(/F$/,"","",$4)}' |
With this InFile ...
Code:
2013/12/09 00:22:16 Temperature 76.10F Code:
awk -F " |F" '{print $1,$2,$4}' $InFile >$OutFile Code:
2013/12/09 00:22:16 76.10 |
With this InFile ...
Code:
2013/12/09 00:22:16 Temperature 76.10F Code:
tr -d '[:alpha:]' <$InFile >$OutFile Code:
2013/12/09 00:22:16 76.10 Daniel B. Martin |
All times are GMT -5. The time now is 09:08 PM. |