1

I'm trying to extract some data from a CSV file, and the command line that works under linux is not working with mawk for windows.

Using WSL, the following command works as expected:

    mawk -F, '$16 == "Good" {print $4}' < *GOL*_approval.txt

However, in powershell, the following command gives completely different results:

    mawk -F',' '$16 == "Good" {print $4}' *GOL*_approval.txt

I think it might be a quoting option, but I've tried everything I can think of.

  • Please, post some sample data with the related expected output and _completely different results_ you got with that data. Don't post them as comments, images, tables or links to off-site services but use text and include them to your original question. Thanks. – James Brown Aug 27 '21 at 17:26

2 Answers2

2
  • PowerShell on Windows doesn't support what is called native globbing in PowerShell (Core) on Unix-like platforms, so you must resolve your globbing (wildcard) pattern explicitly.

  • Up to at least PowerShell 7.1, a long-standing bug when passing arguments to external programs that have embedded " characters requires them to be manually escaped as \"

    • This may finally get fixed in the upcoming v7.2 - see this answer.
# Manual escaping of " as \" is required up to v7.1
# This may change in v7.2
mawk -F',' '$16 == \"Good\" {print $4}' (Get-Item *GOL*_approval.txt).FullName
mklement0
  • 312,089
  • 56
  • 508
  • 622
0

What is your version of mawk? http://gnuwin32.sourceforge.net/packages/mawk.htm ?

Also you are missing a < on the second item before the < *GOL*_approval.txt and putting extra ' in -F','

Rui Claro
  • 43
  • 4