[opensuse] some sed-help, please
Hi all, Need some help with sed: I have a txt file that contains some 15000 lines, where i want to bring in some structure. First is to replace the first (only the first) space in the line with a <TAB>. After that I want to delete a given number of characters that always begin with the same sequence, but may have different contents. Beginning is always the same, and length to delete is also always the same. I used sed 's/^ /\t/' txtfile, but I do not get a tab. Besides, this might do more then just the first space, I guess. Could someone shed some more light here? -- L. de Braal BraHa Systems NL - Terneuzen T +31 115 649333 F +31 115 649444 -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Leen de Braal wrote:
Hi all,
Need some help with sed:
I have a txt file that contains some 15000 lines, where i want to bring in some structure. First is to replace the first (only the first) space in the line with a <TAB>. After that I want to delete a given number of characters that always begin with the same sequence, but may have different contents. Beginning is always the same, and length to delete is also always the same.
I used sed 's/^ /\t/' txtfile, but I do not get a tab. Besides, this might do more then just the first space, I guess.
Could someone shed some more light here?
Something like: sed 's/\s/\t/' test-file | sed 's/pattern......//' Cheers, Dave -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Am Dienstag, 21. August 2007 schrieb Leen de Braal:
First is to replace the first (only the first) space in the line with a <TAB>. After that I want to delete a given number of characters that always begin with the same sequence, but may have different contents.
sed 's/^ /\t/;s/beginning.\{n\}//' works for me, where "beginning" ist the beginning sequence and n is the given number of characters minus the length of "beginning".
I used sed 's/^ /\t/' txtfile, but I do not get a tab.
That works for me.
Besides, this might do more then just the first space, I guess.
No, 's/ /\t/g' would do so. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
Am Dienstag, 21. August 2007 schrieb Leen de Braal:
First is to replace the first (only the first) space in the line with a <TAB>. After that I want to delete a given number of characters that always begin with the same sequence, but may have different contents.
sed 's/^ /\t/;s/beginning.\{n\}//'
works for me, where "beginning" ist the beginning sequence and n is the given number of characters minus the length of "beginning".
Tried it, works! Thanks.
I used sed 's/^ /\t/' txtfile, but I do not get a tab.
That works for me.
I was wrong, is a tab here too. I overlooked it because next tabstop was exactly 1 space away.
Besides, this might do more then just the first space, I guess.
No, 's/ /\t/g' would do so.
Ok, thats good.
-- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
-- L. de Braal BraHa Systems NL - Terneuzen T +31 115 649333 F +31 115 649444 -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
On Tuesday 21 August 2007 01:51, Leen de Braal wrote:
Hi all,
Need some help with sed:
...
I used sed 's/^ /\t/' txtfile, but I do not get a tab. Besides, this might do more then just the first space, I guess.
Assuming you're using bash, you need to use the $'string literal with \t escapes' notation. The dollar sign and single quote marks enable the backslash escapes. If you want to use a newline, it needs to be preceded by a backslash, which will then need to be double, so a newline in a $'...' string will look like $'... \\\n ...'
Could someone shed some more light here?
-- L. de Braal
Randall Schulz -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org
participants (4)
-
Dave Howorth
-
Leen de Braal
-
Randall R Schulz
-
Theo Wollenleben