![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| DUNE (Numerics) 1.1 (Default branch) | iBot | Software Releases - RSS News | 0 | 05-09-2008 03:20 AM |
| Count No of Records in File without counting Header and Trailer Records | guiguy | Shell Programming and Scripting | 2 | 06-07-2007 09:15 AM |
| Conversion to display leading zeros for numerics | dsimpg1 | Shell Programming and Scripting | 4 | 12-02-2005 07:43 PM |
| Drop Users | trfrye | UNIX for Dummies Questions & Answers | 2 | 08-31-2005 12:39 PM |
| deleting records with a missing field | gillbates | UNIX for Dummies Questions & Answers | 2 | 12-12-2002 07:52 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
I have tab delimited file and need to remove all records prior to sort, that have non-numerics in the Field 2. valid/invalid field 2 data examples are:
" 123" valid "1 23" invalid " NOPE" invalid I've tried this awk it does not recognize tab as the delimiter or check all characters in field 2: awk -Ftab '$1 ~ /^[0-9]/ { print $1 }'<$ebs_filter_file I've also played around with sed, but can't seem to get it. Any help would be appreciated! akxeman |
| Forum Sponsor | ||
|
|
|
|||
|
Thanks! Still having an issue with situations that contain both alpha & numeric characters such as "12A3" & "4 6" comes back as valid, when I want to drop them. Is there anything I can put in/around the expression to check all characters in the field?
|
|
|||
|
Code:
awk -F"\t" '{if ($2 !~ /[A-Za-z ]/) {print $2 "\t valid"; } else {print $2 "\t invalid";}}' filename
Code:
123 valid 1 23 invalid 123AB invalid ABD123 invalid 12345 valid NOPE invalid 1234 invalid Code:
awk -F"\t" '$2 !~ /[A-Za-z ]/ { print $0 }' filename
|
|||
| Google The UNIX and Linux Forums |