Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Y15-SUB-B04-P17-BK_M02734_4_000000000-ANNUF_1_1111_24724_4878;size=1;
- Y15-SUB-B05-P22-LM_M02734_4_000000000-ANNUF_1_1111_20624_14973;size=1;
- Y15-SUB-B05-P22-LM_M02734_4_000000000-ANNUF_1_1103_11326_10379;size=1;
- Y15-SUB-B04-P17-BK_M02734:4:000000000-ANNUF:1:1111:24724:4878;size=1;
- Y15-SUB-B05-P22-LM_M02734:4:000000000-ANNUF:1:1111:20624:14973;size=1;
- Y15-SUB-B05-P22-LM_M02734:4:000000000-ANNUF:1:1103:11326:10379;size=1;
- sed 's/_/:/2' old_file > new_file
- sed -i'' 's/_/:/2g' file
- cat script.awk
- match($0,/^[^_]*_/,a){ # match current line to first _ (including) into a[0] variable
- sub(a[0],""); # remove a[0] from current line
- gsub("_",":"); # replace all _ to : in current line
- print a[0]""$0; # ouput a[0] and current line
- }
- awk -f script.awk input.txt
- awk 'match($0,/^[^_]*_/,a){sub(a[0],"");gsub("_",":");print a[0]""$0;}' input.txt
- <field 1>_<field 2>:<field n>:<field n+1>:...
- awk -F_ '{ printf("%s_%s", $1, $2); for (x = 3; x <=NF; x++) { printf(":%s", $x); }; printf("n"); }'
- awk -F_ '{printf("%s_%s:%s:%s:%s:%s:%s:%sn", $1, $2, $3, $4, $5, $6, $7, $8);}'
- Y15-SUB-B04-P17-BK_M02734:4:000000000-ANNUF:1:1111:24724:4878;size=1;
- Y15-SUB-B05-P22-LM_M02734:4:000000000-ANNUF:1:1111:20624:14973;size=1;
- Y15-SUB-B05-P22-LM_M02734:4:000000000-ANNUF:1:1103:11326:10379;size=1;
- sed -i "s/_/:/2g" filename
- perl -pe '{$n=0}s{_}{++$n > 1 ? ":" : $&;}ge' file
- $ sed -e '
- y/_/n/
- s/n/_/
- y/n/:/
- ' inp.file
- $ perl -pe '1 while s/_.*?K_/:/g' inp.file
- #include <stdio.h>
- #include <string.h>
- int main ( int argc, char *argv[] ) {
- FILE *infp = (argc>1? fopen(argv[1],"r") : stdin ),
- *outfp = (argc>2? fopen(argv[2],"w") : stdout );
- char line[9999], *lptr=line, this = '_', that = ':';
- int nskip = 1, nfound = 0;
- if ( infp != NULL && outfp != NULL ) {
- while ( (lptr=fgets(line,9990,infp)) != NULL ) {
- nfound = 0;
- while ( (lptr=strchr(lptr,this)) != NULL ) {
- if ( ++nfound > nskip ) *lptr = that;
- lptr++; }
- if ( fputs(line,outfp) == EOF ) break;
- } /* --- end-of-while(fgets()!=NULL) --- */
- if ( infp != stdin ) fclose(infp);
- if ( outfp != stdout ) fclose(outfp);
- } /* --- end-of-if(in,outfp!=NULL) --- */
- } /* --- end-of-function main() --- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement