Title: sed remove digits at end of the line
Tags: regex;linux;sed
Question: 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'
```

Comment: I think that would only work if you have exactly ten numbers.

Comment: yep, can you improve it to make it work? I've been trying but I cant :s

Here is the accepted answer: 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}$//'
```


Here is another answer: A quick look here suggests you should try this:

```$ sed 's/[0-9]\{0,10\}$//g'
```

{ } should be escaped, unless you switch to extended regex syntax:

```$ sed -r 's/[0-9]{0,10}$//g'
```


Here is another answer: The following should work:

```sed 's/[0-9]\{1,10\}$//' file
```

Regex syntax in ```sed``` requires backslashes before the brackets to use them for repetition, unless you use an extended regex option.


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 3, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2012:00:05/22/12', 'FavoriteCount': 1.0, 'PostTypeId': 1, 'Tags': '<regex><linux><sed>', 'Title': 'sed remove digits at end of the line', 'ViewCount': 9785, 'id': 10707320, 'user_AboutMe': '<p>Computer Engineer / Developer / Entrepreneur / Linux Fanatic</p>\n', 'user_AccountId': 151892.0, 'user_DisplayName': 'Marco A', 'user_Reputation': 109.0, 'user_Views': 18.0, 'user_id': 366033.0}}