{ads}

Removing duplicate characters from a string on Linux with awk



June 14, 2022 at 04:11AM

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 }’
two
 

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



from Network World https://ift.tt/0gd5KrN

0 Response to "Removing duplicate characters from a string on Linux with awk"

Post a Comment

Article Top Ads

Central Ads Article 1

Middle Ads Article 2

Article Bottom Ads