1

I have a fixed width file with 10-15 columns. The file contains alphanumeric values. How do I check for any special characters (like !,@,#,$,% etc.) in the entire file in UNIX ?

kpratihast
  • 842
  • 1
  • 10
  • 23

1 Answers1

1

try this;

grep -vn "^[a-zA-Z0-9]*$" yourFile

or

grep -vn "^[[:alnum:]]*$" yourFile

man grep :

-v, --invert-match Invert the sense of matching, to select non-matching lines.

-n, --line-number Prefix each line of output with the 1-based line number within its input file. (-n is specified by POSIX.)

[[:alnum:]] means the character class of numbers and letters in the current locale

Mustafa DOGRU
  • 3,994
  • 1
  • 16
  • 24