![]() |
Please Help Newbie
Hello,
I have a log file, which I want to use as a word list. Problem is, there's no space between the words and the numbers to which the words are linked. For instance, I need to change called20:12,18 to called 20:12,18 by adding a space between the words and the numbers. sed's info file tells me that replace-strings get interpreted litterally on the right hand side. Thus, as info telle me, sed s/[a-zA-Z][0-9]/[a-z][A-Z]\ \[0-9]/g testfile produces "calle[a-z][A-Z] [0-9]0:12,18" Can someone tell me how I can search my file for all instances of letter-then-number, and replace them with letter-then-space-then-number? Thank you very much. |
Just search for a subpattern containing one or more alphabetics, such as ([a-zA-Z]+), then replace it with the subpattern plus a space. That presumes that your example always represents your data.
|
Here's a copy of a CLI screen
:
C:\DOCUME~1\David\Desktop>type filter.txt |
Just to clarify:
When you want to keep certain sections of the document you're running the regex on, you enclose them in parentheses (brackets - ( and ) ), as DaWei shows. You then use these by using "\1", "\2" etc. in the replace string. |
Well, there's tr as well.
:
cat filename | tr -s ';' ' ' | tr -s ',' ' ' > newfilename |
| All times are GMT -5. The time now is 5:03 PM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC