The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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
string with invalid characters cleopard High Level Programming 4 08-07-2008 05:23 PM
Invalid Characters in the file. kanu_pathak UNIX for Dummies Questions & Answers 15 02-04-2008 08:10 AM
Invalid Characters in the file. kanu_pathak Shell Programming and Scripting 5 02-01-2008 09:45 AM
Shell Script Menus - Rejecting invalid input (KSH) rockysfr Shell Programming and Scripting 2 06-26-2007 04:14 PM
Problem with shell script...ORA-00904:invalid identifier bhagat.singh-j Shell Programming and Scripting 12 11-13-2006 10:33 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-17-2009
beginner82 beginner82 is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 1
writing shell script to find line of invalid characters

Hi,

I have to write s script to check an input file for invalid characters. In this script I have to find the exact line of the invalid character. If the input file contain 2 invalid character sat line 10 and 17, the script will show the value 10 and 17. Any help is appreciated.
  #2 (permalink)  
Old 03-17-2009
daptal daptal is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 68
#!/usr/bin/sh;
cntr=1;
while read myline
do
cntr=`expr $cntr + 1`;
if [ `echo $myline | egrep '[a-z]'` ]; then
echo $cntr;
fi
done < txt

Here i am matching for the lines which contains a-z . Alter ur script accordingly

Cheers
  #3 (permalink)  
Old 03-18-2009
vidyadhar85's Avatar
vidyadhar85 vidyadhar85 is offline Forum Staff  
Moderator(The Tutor)
  
 

Join Date: Jun 2008
Location: INDIA
Posts: 1,418
Quote:
Originally Posted by beginner82 View Post
Hi,

I have to write s script to check an input file for invalid characters. In this script I have to find the exact line of the invalid character. If the input file contain 2 invalid character sat line 10 and 17, the script will show the value 10 and 17. Any help is appreciated.
in that case try

Code:
 
 awk '$0 ~ /anycharacter/{print "line no : "NR}' filename

  #4 (permalink)  
Old 06-04-2009
vgersh99's Avatar
vgersh99 vgersh99 is offline Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131
Quote:
Originally Posted by manaswinig View Post
I need to print lines with character S at nth position in a file...can someone pl help me with appropriate awk command for this
Please don't hijack threads - start your own.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:36 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0