Skip to main content

Posts

Featured

awk - Unexpected outcome from awk when there is multiple delimiter

For example,  $ echo "tom+|dick+|and+|harry" | awk -F '+|' '{print $2}' |dick or $ echo "tom | dick | and | harry" | awk -F ' | ' '{print $2}' | In the above example, one may expect the output as dick. However, both awk output seems unexpected. The reason is - awk -F (as least more recent version of Linux) perform regex. The above  + mean matches character before + one or more times | mean OR operator as a result, above output is given due to regex matching. If you want to literal matching of the delimiter, you need to escape the regex operator with \\ $ echo "tom+|dick+|and+|harry" | awk -F '\\+\\|' '{print $2}' dick or $ echo "tom | dick | and | harry" | awk -F ' \\| ' '{print $2}' dick Reference https://www.computerhope.com/jargon/r/regex.htm

Latest Posts

OpenLDAP - Modifying cn=config attribute

OpenLDAP - Debug logging

Windows Defenders - Windows cannot remove Microsoft.Windows.SecHealthUI_10.0.19041.1023_neutral__cw5n1h2txyewy because the current user does not have that package installed

Linux - passwd "The password is too similar to the old one"

Windows 11 - Restore old Right-click Context menu

Oracle Virtual Box - "Failed to get device handle and/or partition ID" error

Window 11 - "This is no longer located in" error when deleting a directory

WebEx - Code Block with Syntax Highlighting in message

Python - Wait for TCP ack before sending next data

Linux - "cannot execute: required file not found" error