![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| problem with command line | sopel39 | Shell Programming and Scripting | 0 | 11-09-2007 06:27 AM |
| Problem parsing line in file | rlwilli | Shell Programming and Scripting | 2 | 09-02-2006 12:15 PM |
| $line command problem | victorin | Shell Programming and Scripting | 3 | 07-21-2006 11:26 AM |
| Line wrapping problem when using awk | placroix1 | Shell Programming and Scripting | 1 | 05-10-2005 12:44 PM |
| Sed new line problem | Cordially | UNIX for Dummies Questions & Answers | 1 | 03-03-2004 11:53 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
problem with new line
Hi Masters,
Here is the code someone posted days ago, but it didn't work well because it did't omit the newline character when $2 conbines. Can someone help me out? awk '{if($1==prev) printf(" /// "$2); else {printf("\n"$1" " $2);prev=$1}}' Basically, this code is trying to remove the redundent line in a two column spreadsheet file based on the field one, but merge field 2 if field one is redundent. Thanks in advance. |
|
||||
|
Thanks! You are right. So I am fraid of violating rules again. But the basic idea is,
H82421 RDH11 H82421 DKFZP564M1462 H82435 BAGE4 H82435 MLL3 H82527 C20orf17 H82532 - H82706 ID2 H82801 - H82812 TNRC6B H82872 UACA What I need, H82421 RDH11 /// DKFZP564M1462 H82435 BAGE4 /// MLL3 H82527 C20orf17 H82532 - H82706 ID2 H82801 - H82812 TNRC6B H82872 UACA Your code gave the line break in between $2, H82421 RDH11^M /// DKFZP564M1462 H82435 BAGE4^M /// MLL3 H82527 C20orf17 H82532 - H82706 ID2 H82801 - H82812 TNRC6B H82872 UACA I could use some text editor to remove line breaks, but thought the complete code could be helpful for other people too. In addition, if the redundent lines are not sorted, what code should be? Thanks so much. |
|
||||
|
Thank you all. Both of your code generated almost same output in terms of line breaks, second code didn't work with multiple redundent lines.
First output, AA001897 SPTA1 AA001918 MI-ER1^M /// ER1^M /// KIAA1610^M /// DKFZp781G0451 AA001924 Cep63^M /// FLJ13386 AA001950 KIF13A AA001952 - AA001970 - AA001976 - Second output, AA001897 SPTA1 AA001918 MI-ER1^M /// ER1 AA001918 MI-ER1^M /// KIAA1610 AA001918 MI-ER1^M /// DKFZp781G0451 AA001924 Cep63^M /// FLJ13386 AA001950 KIF13A AA001952 - AA001970 - AA001976 - AA002006 - I just wonder if this is my os problem or not. I am using Mac OS X, and bash shell. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|