sed remove digits at end of the line
linux, regex, sed
Solution
Have you tried this:
sed 's/[0-9]+$//'
Your command would only match and delete exactly 10 digits at the end of line and only, if you enabled extended regular expressions (-E or -r, depending on your version of sed).
You should try
sed -r 's/[0-9]{1,10}$//'
Problem
I need to find out how to delete up to 10 digits that are at the end of the line in my text file using sed. For example if I have this: ``` ajsdlfkjasldf1234567890 asdlkjfalskdjf123456 adsf;lkjasldfkjas123 ``` it should become: ``` ajsdlfkjasldf asdlkjfalskdjf adsf;lkjasldfkjas ``` can anyone help? I have this, but its not working: ``` sed 's/[0-9]{10}$//g' ```