This is not removing first 4 letters, this is to replace first 4 characters as . means single character. And if your line started with things like space, underscore and etc, it will match too as long as it is single character that matching 4 times.
The more correct way to do this is using
sed -s 's/^[[:alpha:]]\{4\}//g' file
Or
sed -s 's/^[a-zA-Z]\{4\}//g' file
Now this is really "letter"(and you match whether it is upper or lower case, by the way it is wrong also that you call it as removing first 4 letters in your regex, because ^ is to match start of the line.
Be careful when building the regex, it can be tricky to get it right sometime.
By the way, I just wanted to remove numbers when you view in vim. Since line numbering in vim are right aligned, the smaller numbers are preceded with spaces before the number itself. For this I need to include spaces for removal.
Hey codept,
ReplyDeletesed 's/^.\{4\}//g' test.txt
This is not removing first 4 letters, this is to replace first 4 characters as . means single character. And if your line started with things like space, underscore and etc, it will match too as long as it is single character that matching 4 times.
The more correct way to do this is using
sed -s 's/^[[:alpha:]]\{4\}//g' file
Or
sed -s 's/^[a-zA-Z]\{4\}//g' file
Now this is really "letter"(and you match whether it is upper or lower case, by the way it is wrong also that you call it as removing first 4 letters in your regex, because ^ is to match start of the line.
Be careful when building the regex, it can be tricky to get it right sometime.
Cheers ;]
Thanks geek00l!
ReplyDeleteBy the way, I just wanted to remove numbers when you view in vim. Since line numbering in vim are right aligned, the smaller numbers are preceded with spaces before the number itself. For this I need to include spaces for removal.
@geek00l:
ReplyDeleteThanks! Exactly what I needed, worked like a charm :)
Cheers,
MR
NICE . IT WORKS !
ReplyDeleteGREAT ! it works !
ReplyDeleteNICE . IT WORKS !
ReplyDeleteYep works great.. ! Thanks you
ReplyDelete