Hey so I want to replace a regex pattern with nothing, I've tried multiple sed routes but none seem to be working, i.e
sed -i 's/\.\d{1,3}\b$//'
Example of input,
Hello.123
Hello.123.90
expected output would be,
Hello
Hello.123
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It only takes a minute to sign up.
Sign up to join this communityHey so I want to replace a regex pattern with nothing, I've tried multiple sed routes but none seem to be working, i.e
sed -i 's/\.\d{1,3}\b$//'
Example of input,
Hello.123
Hello.123.90
expected output would be,
Hello
Hello.123
Maybe yo can try something like this:
sed -i -E 's/\.[0-9]{1,3}$//' file
.
followed by 1 to 3 numbers from each line? What if a line isfoo.1234
? Should we leave that unchanged?foo.1234
? Nothing? Do we just print the line?