writing shell script to find line of invalid characters


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting writing shell script to find line of invalid characters
# 1  
Old 03-17-2009
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  
Old 03-18-2009
#!/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  
Old 03-18-2009
Quote:
Originally Posted by beginner82
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  
Old 06-04-2009
Quote:
Originally Posted by manaswinig
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Script to find common lines and replace next line

I want to find common line in two files and replace the next line of first file with the next line of second file. (sed,awk,perl,bash any solution is welcomed ) Case Ignored. Multiple Occurrence of same line. File 1: hgacdavd sndm,ACNMSDC msgid "Rome" msgstr "" kgcksdcgfkdsb... (4 Replies)
Discussion started by: madira
4 Replies

2. Shell Programming and Scripting

Find new line characters in a file

Hi All, I need to find new line characters in a file and their location in the file and print the results. can someone pleas help. KM (4 Replies)
Discussion started by: Kevin Tivoli
4 Replies

3. Shell Programming and Scripting

Need some help writing a find script

hello all! well, here is my problem: i have to write a script which waits for a directory as an argument and scans it recuresively and than it prints those files, which have write permission for everyone (as relative path from the argument directory so the find will be the key). and it shouldnt... (9 Replies)
Discussion started by: Mixe3y
9 Replies

4. UNIX for Dummies Questions & Answers

Invalid option errors running shell script

The script below fails with the following error messages: gzip: invalid option -- 'w' Try `gzip --help' for more information. mysqldump: Got errno 32 on write cp: invalid option -- 'w' Try `cp --help' for more information. rm: invalid option -- 'w' Try `rm --help' for more information. ... (1 Reply)
Discussion started by: ANNACTION
1 Replies

5. Shell Programming and Scripting

How to find invalid URL in a text file using shell script?

How to find and remove invalid URLs in a text file using shell script? (1 Reply)
Discussion started by: vel4ever
1 Replies

6. Shell Programming and Scripting

Single/Multiple Line with Special characters - Find & Replace in Unix Script

Hi, I am creating a script to do a find and replace single/multiple lines in a file with any number of lines. I have written a logic in a script that reads a reference file say "findrep" and populates two variables $FIND and $REPLACE print $FIND gives Hi How r $u Rahul() Note:... (0 Replies)
Discussion started by: r_sarnayak
0 Replies

7. UNIX for Dummies Questions & Answers

shell script to find noof characters in a file name

hiiii shell script to find noof characters in a file name, when you run ls -l (using awk) I tried with this ls -l > temp awk -F"," '{print $1 " " expr length $9}' temp but it give some other value instead of file name length (error value like , 563,54,55,56....).How to prnint the... (10 Replies)
Discussion started by: krishnampkkm
10 Replies

8. Shell Programming and Scripting

shell script to find and replace a line using a identifier

Hi all im having trouble starting with a shell script, i hope someone here can help me i have 2 files file1: 404905.jpg 516167 404906.jpg 516168 404917.psd 516183 404947.pdf 516250 file2: 516250 /tmp/RecyclePoster18241.pdf 516167 /tmp/ReunionCardFINAL.jpg 516168... (7 Replies)
Discussion started by: kenray
7 Replies

9. Shell Programming and Scripting

Shell Script Menus - Rejecting invalid input (KSH)

Greetings all, I'm currently writing a shell script menu which is dynamically populated from an array. Have a question to ask about the filtering of invalid input. I'm using KSH. A brief description of my algorithm is as follows: 1) Read in input from user and store in a variable. (a valid... (2 Replies)
Discussion started by: rockysfr
2 Replies

10. Shell Programming and Scripting

Problem with shell script...ORA-00904:invalid identifier

Guys, Please suggest me what's wrong with this script? #!/usr/bin/sh ############################################################################## # Author : Bhagat Singh # # # Date : Nov 13,2006 #... (12 Replies)
Discussion started by: bhagat.singh-j
12 Replies
Login or Register to Ask a Question