Hello and thanks for the help.
I'm having difficulty escaping the single quote character (') in a Windows Batch script. I've tried ^', \', ''', '\'', and so on. Online searches haven't solved it either. I'm stumped.
This script uses cgywin64 gawk to format a list of folders:
@echo off
du -sk ./* | sort -nr | head -40 | gawk '{printf("%%^'14d kB %%s %%s %%s %%s %%s %%s %%s %%s\n", $1, $2, $3, $4, $5, $6, $7, $8, $9)}'
When run, it gives me the following errors:
gawk: cmd. line:1: {printf("%^14d
gawk: cmd. line:1: ^ unterminated string
gawk: cmd. line:1: {printf("%^14d
gawk: cmd. line:1: ^ syntax error
Without doing any character escaping, the gawk command would look something like:
gawk '{printf("%'14d kB %s %s %s %s %s %s %s %s\n", $1, $2, $3, $4, $5, $6, $7, $8, $9)}'
The format string at the beginning (%'14d) tells gawk to use commas when printing the integer ("123456789" prints as "123,456,789"). This string has a single quote ('), which I can't figure out how to pass into the batch script without errors.
So how do I pass a single quote (') into a batch script?
Any help appreciated.