Sed + regex is not matching and replacing occurence with d
I am trying to remove the numbers at the start of the line with the following command:
sed -i 's/^d*t//' sea_news_2020_corpus.txt
The line looks as follows:
809940 The sea will be moderate in the Arabian Gulf and slight to moderate in Oman.
Why does this not work? Tried it for a long time
Sed does not understand d for a number. For that use [0-9] or more correctly [[:digit:]]
sed -i 's/^[0-9]*t//' yourfile
- t is not universally understood by sed. POSIX does not mandate it. So use a shell variable for that or slip in an escaped TAB using a construct inspired from ksh $’t’
- in place edits -i on Mac needs an argument following it , though GNU is forgiving here. Note that -i is not mandated by Posix.
sed -i"" -e $'s/^[[:digit:]]*t//' input_file
TAB=$(echo x | tr x ' 11') # or $(printf 't') sed -i"" -e "s/^[[:digit:]]*$TAB//" input _file