Script to edit a text file

hi, could someone share a short script that would process a .txt file and do the following, for example the text file has this form

0:1.0 1:1.0 2:2.0 3:3.0 4:4.0 5:5.0 6:6.0 7:7.0 8:8.0 ... {newline}
9:9.0 10:10.0 11:11.0 12:12.0 13:13.0 14:14.0 15:15.0 16:16.0 17:17.0 ... {newline}

and I would like the number before the column to be removed and the number after the column from float format to be converted in integer format and the newline to be respected, like:

1 2 3 4 5 6 7 8 ... {newline}
9 10 11 12 13 14 15 16 17 ... {newline}

Please note the {spaces} in between are important to be respected.

thank you very much!

Try:

sed 's/[0-9]*://g;s/\.[0-9]*//g' inputfile
1 Like
perl -lane 'for(@F){s/\d+?:(\d+?)\.\d+/$1/}; print "@F"' file
sed 's![^:]*:\([0-9]*\)\.[0-9]*!\1 !g' file
1 Like

With awk

awk '{gsub(/[0-9]*:/,"");gsub(/\.[0-9]*/,"")}1'
1 Like