|
Search Forums:
|
|||||||
| Forums | Register | Forum Rules | Linux and Unix Links | Man Pages | Albums | FAQ | Users | 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. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Delete row if a a particular column has more then three characters in it
Hi i have a data like Code:
hw:dsfnsmdf:39843 chr2 76219829 51M atatata 51 872389 hw:dsfnsmdf:39853 chr2 76219839 51M65T atatata 51 872389 hw:dsfnsmdf:39863 chr2 76219849 51M atatata 51 872389 hw:dsfnsmdf:39873 chr2 76219859 30M32X atatata 51 872389 I want to dalete all the rows having more then 3 charecters in 4th coloumn sample output Code:
hw:dsfnsmdf:39843 chr2 76219829 51M atatata 51 872389 hw:dsfnsmdf:39863 chr2 76219849 51M atatata 51 872389 Can anyone help me out how to do this. Thanks. Last edited by joeyg; 02-08-2012 at 02:09 PM.. Reason: Please wrap examples and scripts with CodeTags |
| Sponsored Links | |
|
|
|
#2
|
||||
|
||||
|
Perhaps something like...
Code:
awk 'if (length($4)<=3) print $0 <datafile You may need to add a delimiter, though. Unsure if spaces or tab or ?? between fields. Last edited by joeyg; 02-08-2012 at 02:45 PM.. |
| The Following User Says Thank You to joeyg For This Useful Post: | ||
bhargavpbk88 (02-08-2012) | ||
| Sponsored Links | ||
|
|
|
#3
|
|||
|
|||
|
Try this.
Code:
awk '{if (lenght($4)<=3) {print $0}}' datafile |
| The Following User Says Thank You to ezitoc For This Useful Post: | ||
bhargavpbk88 (02-08-2012) | ||
|
#4
|
|||
|
|||
|
You can reduce that: Code:
awk 'length($4) <= 3' datafile |
| The Following User Says Thank You to Corona688 For This Useful Post: | ||
bhargavpbk88 (02-08-2012) | ||
| Sponsored Links | ||
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| SED help delete characters in a string | redtred | Shell Programming and Scripting | 7 | 08-31-2011 07:46 AM |
| Removing last ten characters from a column | e3r1ck_ETT | UNIX for Dummies Questions & Answers | 9 | 03-23-2009 04:20 PM |
| Delete not readable characters | ajilesh | Shell Programming and Scripting | 3 | 12-14-2008 01:11 PM |
| how to delete M-^M characters from a file | hyennah | UNIX for Dummies Questions & Answers | 1 | 11-20-2008 05:17 PM |
| Delete specific characters | masquerer | AIX | 4 | 04-21-2008 05:00 AM |
|
|