|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | 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
|
|||
|
|||
|
Check if the text file has more than 2 characters
Guys, I know that the below command will cut the 13th field from test.txt file Code:
awk -F"|" '{print $13}' test.txtThe answer would be, Code:
If we see the 3 rd one, it has more than 2 characters. So i wanted to check this in if condition and i want to get the output if the 13th field has more than 2 characters. ![]() Any help would be greately appreciated!!! Last edited by Franklin52; 12-19-2012 at 02:20 AM.. Reason: Please use code tags for data and code samples |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
Code:
awk -F'|' 'length($13)>2' inputfile > outputfile |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Thank you! Great...
It worked fine.. But this displaying the whole content.. Is there any way to display particular 13th field? |
|
#4
|
|||
|
|||
|
Try... Code:
awk -F'|' 'length($13)>2 {print $13}' inputfile > outputfile |
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Cool. Thank you
![]() |
| Sponsored Links | ||
|
![]() |
| Tags |
| perl 5.8.8, unix alert script, unix commands, unix scripting |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Any way to get rid of ^M characters in a text file using pr? | Nonito84 | UNIX for Dummies Questions & Answers | 2 | 10-26-2011 05:44 PM |
| Help with deleting characters from text file | evelibertine | UNIX for Dummies Questions & Answers | 1 | 06-28-2011 01:24 PM |
| How to check if the file has EBCDIC or ascii characters | ahmedwaseem2000 | Shell Programming and Scripting | 1 | 07-02-2010 08:46 AM |
| Remove special characters from text file | kkb | Shell Programming and Scripting | 10 | 12-07-2009 10:14 PM |
| Read text from a file between two characters.. | goutam_igate | Shell Programming and Scripting | 2 | 04-16-2009 08:59 AM |
|
|