Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Error handling for file

Shell Programming and Scripting


Tags
error, file, handle, pipe

Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 01-08-2013
Rizzu155 Rizzu155 is offline
Registered User
 
Join Date: Apr 2012
Last Activity: 19 January 2013, 8:22 PM EST
Posts: 5
Thanks: 5
Thanked 0 Times in 0 Posts
Error handling for file

Hi Guys,
I got a csv with pipe delimted file and i want to check second column of the file has any alpha character becuase I am expecting only number in that,
and if any alpha characters then it should throw an error

Thanks in advance
Sponsored Links
    #2  
Old Unix and Linux 01-08-2013
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 5 December 2016, 2:45 PM EST
Location: Amsterdam
Posts: 11,102
Thanks: 440
Thanked 3,109 Times in 2,750 Posts
Try:

Code:
awk -F\| '$2~/[[:alpha:]]/{print "Alpha alert, oh no..."}' file

Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Error handling Learn4Life Shell Programming and Scripting 5 08-10-2012 02:05 AM
Perl file handling error Beginer123 Shell Programming and Scripting 8 06-07-2012 04:50 AM
Error Handling ambarginni Shell Programming and Scripting 4 02-16-2012 02:03 AM
Sum up a decimal column in a tab separated text file and error handling pssandeep UNIX for Dummies Questions & Answers 5 02-24-2010 10:05 AM
Error Handling CelvinSaran Shell Programming and Scripting 5 11-23-2009 01:15 PM



All times are GMT -4. The time now is 08:46 PM.