move a pattern to the beginning of a line with sed
how can i move a pattern to the beginning of the line? 1702,1833,09C4,098C:325F|Sky|sportdigital|TV|Sky sonstige should be 325F:1702,1833,09C4,098C|Sky|sportdigital|TV|Sky sonstige i figured out that i can insert a char or a word to the beginning when my pattern is found. but i don't get it to move my searched pattern... sed -r '/(:325F)/ s/^/#/' this puts a "#" to the beginning when my pattern ":325F" is found. when i do this: sed -r '/(:325F)/ s/^/\1/' it gives me an error... has anyone some tips to get me in the right direction? br chris
You directly use find and replace in sed. sed 's/^\([^:]*\):\([^|]*\)/\2:\1/' file Example: $ echo '1702,1833,09C4,098C:325F|Sky|sportdigital|TV|Sky sonstige' | sed 's/^\([^:]*\):\([^|]*\)/\2:\1/' 325F:1702,1833,09C4,098C|Sky|sportdigital|TV|Sky sonstige $ echo '1702,1833,09C4,098C:325F|Sky|sportdigital|TV|Sky sonstige' | sed 's/^\([^:]*\):325F/325F:\1/' 325F:1702,1833,09C4,098C|Sky|sportdigital|TV|Sky sonstige
Extract resolution from string
How do I create a Scala Regex that is compiled using Java Pattern.COMMENTS?
Is there a way to search terms in order with RegexpQuery in lucene?
Regex to allow any charcter EXCEPT backslash
Regex: Match a condition, then find the first occurrence of another condition that precedes it on the same line. Possible?
Regex for URL routing - match alphanumeric and dashes except words in this list
R: gsub and capture
Trouble with regex in Perl
Duplicate symbols in regular expressions
NSRegularExpression to remove the rest codes
Regex replace in sublimetext2
Regular Expression Search Replace all non leading tabs with single space Notepad++
Django regular expression on success format
Reg ex required for finding two ||
regex from first character to the end of the string
How can I recognize the following group of strings using a grammar or regex?