awk gawk print just numbers,characters, special characters remove special characters , and normal characters


PRINT ONLY NUMBERS WITH AWK 

REPLACE WHAT IS NOT A NUMBER WITH NOTHING (^ inside the first [ means REPLACE IF IS NOT A NUMBER)

gsub(/[^[:digit:]]/,"")

APPLICATION remove SPECIAL CHAR

echo '

[]] çà*+}{
 ¹²³asdfa é
123]] çà*+}{
 ¹²³ ä, ö, ü e ß
'| awk '{gsub(/[^[:digit:]]/,"");print}'

OUTPUT
123

PRINT ONLY SPECIAL CHARACTERS WITH AWK 

echo '

[]] çà*+}{
 ¹²³asdfa é
123]] çà*+}{
 ¹²³ ä, ö, ü e ß
'| awk '{gsub(/[[:alnum:]]/,"");print}'

OUTPUT

[]] *+}{
 ¹²³ 
]] *+}{
 ¹²³ , ,   

PRINT ONLY CHARACTERS WITH AWK 

LL_ALL=de_DE.UTF-8 Set the localization to DE so it now can recognize like special characters even é and ä, ö, ü e ß , you could even set to LL_ALL=C with the same result.

echo '

[]] çà*+}{
 ¹²³asdfa é
123]] çà*+}{
 ¹²³ ä, ö, ü e ß
'| LC_ALL=de_DE.UTF-8  awk '{gsub(/[^[:alnum:]]/,""); gsub(/[[:digit:]]/,"");print}'

OUTPUT



asdfa

e

PRINT ONLY CHARACTERS AND SPECIAL CHARACTERS WITH AWK 

echo '

[]] çà*+}{
 ¹²³asdfa é
123]] çà*+}{
 ¹²³ ä, ö, ü e ß
'|   awk '{gsub(/[^[:alnum:]]/,""); gsub(/[[:digit:]]/,"");print}'

OUTPUT


çà
asdfaé
çà
äöüeß


PRINT ONLY CHARACTERS AND SPECIAL CHARACTERS FOR A LANGUAGE WITH AWK AND ICONV 

in this example i will remove just GERMANS SPECIAL CHARACTERS keppeing ITALIAN SPECIAL CHARACTER

echo '

[]] çà*+}{
 ¹²³asdfa é
123]] çà*+}{
 ¹²³ ä, ö, ü e ß α
'|   awk '{gsub(/[^[:alnum:]]/,""); gsub(/[[:digit:]]/,"");print}' |iconv -t EBCDIC-IT//IGNORE 2>/dev/null | iconv -f  EBCDIC-IT 



çà
asdfaé
çà
e


Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: