This post discusses how to validate both localized and non-localized user input in the POSIX shell.
|
||
Here is how to check for and display lines from a text file that contain control characters except for line endings (which are also control characters!). $ grep “[^[:print:]]” infile | cat -nvt Here is a simple script that will output a message if a text file contains any control characters other than line endings. #!/bin/bash if grep “[^[:print:]]” infile > /dev/null 2>&1 then printf “Control characters present in filen” else printf “No control characters in filen” fi This should work in all locales. |
||
Copyright © 2007-2024 Finnbarr P. Murphy. All Rights Reserved |