Skip to content

Removing duplicate characters from a string on Linux with awk

The awk command can make it easy to remove duplicate characters from a string even when those characters aren’t sequential, especially when the process is turned into a script.

First, the awk command that we’ll be using starts by running through each letter in the string. In a more common command, you might see awk doing something like this:

$ echo one:two:three | awk ‘BEGIN {FS =”:”} ; { print $2 }’

[ Get regularly scheduled insights by signing up for Network World newsletters. ]


The FS portion of that command specifies the field separator—the character that is used to separate the fields in the string so that they can be processed separately.

To read this article in full, please click here

Source:: Network World – Data Center