Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sed: remove numbers from file

Tags:

regex

bash

unix

sed

I'm trying to remove all words from a file that contain a number

Attempt

sed -r 's/\w*\d\w*//g' file.txt

Sample file.txt:

12.23 worda
01234 wordb
wordc
fe424 wordd 
a232efe424 worde 7
a232efe424 wordf wordg 7
a232efe424 wordh h5f

Desired ouput:

worda
wordb
wordc
wordd
worde
wordf wordg
wordh
like image 868
jamesmstone Avatar asked Apr 15 '26 12:04

jamesmstone


1 Answers

sed oneliner

sed -r 's/[^[:space:]]*[0-9][^[:space:]]* ?//g'
like image 196
pakistanprogrammerclub Avatar answered Apr 18 '26 00:04

pakistanprogrammerclub