Using sed how it is possible??
hi all,
im having problems. I need to change all number 10 in a text file to word form, or in short from 10->ten. the thing is number 10 including in dates such as 10/22/1997 or 03-10-2011 should not be changed. im having some trouble because the file contains numbers like "price range from 10-50k". this is just a sample. name: john smith birthday: 10-11-1995 date hired: 05/10/2010 expected salary: 10-50k typing speed: 10 wpm coordinates: (10, 10) should come out like this: name: john smith birthday: 10-11-1995 date hired: 05/10/2010 expected salary: ten-50k typing speed: ten wpm coordinates: (ten, ten) Using sed command is it possible to change like this.. please guide me!! |
Try the following:
Code:
sed -e '/day/ !s/10/ten/g' -e '/date/ !s/10/ten/g' file |
Hi
If i execute this commad Code:
sed -e '/day/ !s/10/ten/g' -e '/date/ !s/10/ten/g' sed1 Quote:
|
Quote:
Code:
sed -E '/day|date/ !s/10/ten/g' file |
Code:
sed -E '/day|date/ !s/10/ten/g' file are u damn sure...ie caps -E beacuse it shows error!!! I think we cant able to use -E option in sed command!!! |
It works for me:
Code:
sycamorex@thinkslack:~/temp/ttt$ cat file.txt Code:
sed --version |
GNU sed version 4.1.5
Copyright (C) 2003 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, to the extent permitted by law can u post your version?? that means i can update!!! |
I am using 4.2.1. Can you try with the -r flag instead of -E?
|
Thanks for Your immediate response!!
It works like charm!!! |
Having done some googling, it turns out that I should have used -r in the first place.
The -E flag is added just to provide compatibility with the BSD version of sed. The standard flag for extended regular expressions in GNU Sed is -r. http://stackoverflow.com/questions/3...ed-e-and-sed-e |
Hi
Thanks a ton!!! :-) |
Ruby(1.9+)
Code:
$ cat file |
All times are GMT -5. The time now is 05:20 AM. |