I want to change some characters in a string I create. I make a filelisting and from each file I need to append the "stat" information. For example filename "K181_111126.CATProduct" results in "K181_111126.CATProduct.2011-11-28 13:33:33.722342000 +0100". The last 16 characters I don´t need, I solved it with:
find . -type f -exec stat -c%n.%y {} \; | sed 's/.\{16\}$//'
Result: "K181_111126.CATProduct.2011-11-28 13:33:33"
My problem is, that I need to change the space (9th character from behind) between date and time with a "-" and all ":" in the time (13:33:33) with a dot "."
The strings all have different length, so that I can only count from behind.
find's built-in-printfdate-time options e.g.find . -type f -printf '%f.%Tx-%TH.%TM.%TS\n' | sed 's/\.[^.]*$//'