Searching invalid character in list of client name


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Searching invalid character in list of client name
# 1  
Old 10-28-2014
Searching invalid character in list of client name

Hi Friend,

I have a client name list and client name has some invalid character due to which some issue raised and list of client are15k.

I want to make script who find invalid character name.

can you please help me how i can make script, i means i need logic.

Valid character are :-

Alpha
Numeric
space
backslash
'
&
()
{}
date
tab
CF
# 2  
Old 10-28-2014
Your request is a bit difficult to understand. What be the CF char? What is "date"? For the others, you don't need a script but can use e.g. grep with a regex like
Code:
[^[:alnum:] \\'&(){}]

# 3  
Old 10-28-2014
HI RudiC,

Thanks for reply, but CF means next line character, but what about space

---------- Post updated at 06:26 AM ---------- Previous update was at 06:18 AM ----------

HI Rudic,

I tried above command , but it giving error

Code:
grep [^[:alnum]&] client.txt
[] imbalance
[1]24313878
rush : ] not found

---------- Post updated at 06:35 AM ---------- Previous update was at 06:26 AM ----------

And my file is like this
Code:
pallvi mahajan
Sunny Sapen
F.K.S enterprise
London & university
Banker's & Banker
Kapil/ yadav

I need to search name which has not valid character

I have list of valid character
Code:
A alpha only
N numeric only
A/N character which falls in range a-z 0-9 with space
x character set is as follows / - ? CR LF  space
d date

Appreciate if some can help me in this, i need to submit my stomcript morrow

Last edited by Franklin52; 10-28-2014 at 11:11 AM.. Reason: Fixed code tags
# 4  
Old 10-28-2014
Submit tomorrow - is that homework?
The error is due to you not copying the proposal correctly.
# 5  
Old 10-28-2014
No No homework, am working and i need this script to minimize my work in office
# 6  
Old 10-28-2014
grep [^[:alnum]&] client.txt is incorrect for various reasons.
You are missing a colon at the end of alnum, before ]; to make it an alphanumeric class set
[:alnum:] Search some more for it if you want to know what that set would include.
The [^] means exclude the following
The & has to be escaped or protected, since it has special meaning for the shell

In English, it says to grep:
search in the file client.txt for any character that is not an alphanumeric or an ampersand.

Therefore it would show:
Code:
# single quotes to protect the & from the shell
grep '[^[:alnum:]&]' client.txt
pallvi mahajan # shows because there is a space
Sunny Sapen   # same as above
F.K.S enterprise # it shows because periods and space
London & university # it shows because spaces
Banker's & Banker # it shows because spaces and (')
Kapil/ yadav # it shows because (/) and space

Let's add spaces into the exclusion class set
Code:
# there is a space inside the outer [] before &
grep '[^[:alnum:] &]' file
F.K.S enterprise # this shows now because the (.)
Banker's & Banker # this shows because (')
Kapil/ yadav #this shows because (/)

Let's exclude the (') from the list of wanted. Since (') has special meaning for the shell we have to change the quoting scheme that we use.
Code:
# \' and \& will do it
grep "[^[:alnum:] \'\&]" 
F.K.S enterprise
Kapil/ yadav

I think this should be enough, now, to understand and figure out what you must do. Take another look at RudiC's initial exclusion class set.

Last edited by Aia; 10-28-2014 at 02:34 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find invalid character

HI Team, I have script to find the invalid character in file. f=’pallvi\mahajan’ n=0 while (( $n <= ${#f} )); do c="${f:$n:1}" echo '$c' if *] ]]; then grep -sq $c valid.txt if ; then echo "$f" >> f.txt break fi fi (18 Replies)
Discussion started by: pallvi_mahajan
18 Replies

2. AIX

Bison -pap_expr_yy invalid character:% unexpected "identifier" while running make for Apache2.4.3 64

The Follwing packages are installed on my AIX 6.1 box gcc-4.7.2-1 gcc-c++-4.7.2-1 gcc-cpp-4.7.2-1 gcc-gfortran-4.7.2-1 libgcc-4.7.2-1 libgomp-4.7.2-1 libstdc++-4.7.2-1 libstdc++-devel-4.7.2-1 gmp-5.0.5-1 libmpc-1.0.1-2 libmpc-devel-1.0.1-2 libmpcdec-1.2.6-1 libmpcdec-devel-1.2.6-1... (0 Replies)
Discussion started by: Ashish Gupta
0 Replies

3. Shell Programming and Scripting

Searching Alphanumeric Character From a File

Hi, In a error log file, the error code of a particular error contains both Alphabet and Numbers. My problem statement is to find the error codes from a particular log. That means, I need to search a word, which contains both alphabet and number. Please help me. Below is two examples of error... (1 Reply)
Discussion started by: snehasish_jana
1 Replies

4. UNIX for Dummies Questions & Answers

Exclude new line character while searching

Hi, I have a log file and want to search "0.48976360737438795" with excluding new line character. Currently i am using the following command: cat LogFile.log | tr -d '\n' | grep '0.48976360737438795' This command giving me the response if file size is small but if i am using a big file... (11 Replies)
Discussion started by: ankit jain
11 Replies

5. Shell Programming and Scripting

Awk: Searching for length of words between slash character

Dear UNIX Community, I have a set of file paths like the one below: \\folder name \ folder1 \ folder2 \ folder3 \ folder4 \\folder name \ very long folder name \ even longer name I would like to find the length of the characters (including space) between the \'s. However, I want... (6 Replies)
Discussion started by: vnayak
6 Replies

6. Solaris

An invalid XML character (Unicode: 0x1a)

While uploading an exl file to my application in Solaris 10 the upload failed with error Error! Parsing Error: /SPLM/TC83/tcdata83/model/model_dbextract.xml Line:65576 Column:73 An invalid XML character (Unicode: 0x1a) was found in the value of attribute "unitOfMeasureSymbol" and element is ... (12 Replies)
Discussion started by: karghum
12 Replies

7. Linux

Invalid Character

Hi, I am using a Perl script to generate a report file in Linux server. When my input data contains an invalid character which looks like hyphen after that my program is printing junk values in the report. Why that symbol is causing issue and is there a way to tell the server that this is a valid... (1 Reply)
Discussion started by: lawrance_ps
1 Replies

8. UNIX for Dummies Questions & Answers

Searching a particular character in a file

Hi, I want to search how many times is "a" present in a file named "data". How to do this? Please help (4 Replies)
Discussion started by: gautamshaw
4 Replies

9. Shell Programming and Scripting

Searching a string for a character

I have a co-worker that is trying to make a Wheel of Fortune game and he wants to know if there is a way to search a string for the letter given by the user. (7 Replies)
Discussion started by: turbulence
7 Replies

10. UNIX for Dummies Questions & Answers

searching for $ character

I need to search in text files for the $ character. I tried putting it in double quotes and single quotes . ie grep "$" filename but unix finds everything in the file. Whats the best way to do this? thanks (4 Replies)
Discussion started by: MizzGail
4 Replies
Login or Register to Ask a Question