Reputation: 63
I am running this command on my log files,
grep "." file | tr '|' '\n' | sed -r "s/(.{3}).*?\.cpp/\1TRY/g" | tr '\n''|'
It runs as expected i.e. keeping the first three letters same to files with .cpp
extension, adds TRY
to it.
So if input is: abcdef.cpp
ouput is: abcTRY
(keeping words without extension as it is)
But is stops running(gets stuck) after some time, any suggestions on what might be the problem.
Upvotes: 0
Views: 293
Reputation: 174696
Remove the non-greedy quantifier.
sed -r "s/^(.{3})[^.]*\.cpp/\1TRY/"
Upvotes: 4