Skip to main content
added 247 characters in body
Source Link
ilkkachu
  • 148.1k
  • 16
  • 268
  • 441
for f in /etc/passwd; 

This is a bit silly as there's really no loop with just one value.

But the issue seems to be printing single quotes from awk. You could escape them in the shell, but you could also use backslash-escapes within awk to print them. \xHH<i>OOO is the character with numerical value HHOOO (hexin octal), so \x27\047 is '. So this would be one way to do it:

awk -F: -vID=$ID_minimum '$3>=1000 && $1!="nfsnobody" { printf "xfs_quota -x -c \x27limit\047limit bsoft=5g bhard=6g %s\x27%s\047 /home\n", $1}' /etc/passwd 

You could use the similar escape in hex, \x27, but it can get misinterpreted in some implementations if the following character is a valid hexadecimal digit. (And of course I assumed ASCII or an ASCII-compatible character set, e.g. UTF-8.)

for f in /etc/passwd; 

This is a bit silly as there's really no loop with just one value.

But the issue seems to be printing single quotes from awk. You could escape them in the shell, but you could also use backslash-escapes within awk to print them. \xHH is the character with numerical value HH (hex), so \x27 is '. So this would be one way to do it:

awk -F: -vID=$ID_minimum '$3>=1000 && $1!="nfsnobody" { printf "xfs_quota -x -c \x27limit bsoft=5g bhard=6g %s\x27 /home\n", $1}' /etc/passwd 
for f in /etc/passwd; 

This is a bit silly as there's really no loop with just one value.

But the issue seems to be printing single quotes from awk. You could escape them in the shell, but you could also use backslash-escapes within awk to print them. <i>OOO is the character with numerical value OOO (in octal), so \047 is '. So this would be one way to do it:

awk -F: -vID=$ID_minimum '$3>=1000 && $1!="nfsnobody" { printf "xfs_quota -x -c \047limit bsoft=5g bhard=6g %s\047 /home\n", $1}' /etc/passwd 

You could use the similar escape in hex, \x27, but it can get misinterpreted in some implementations if the following character is a valid hexadecimal digit. (And of course I assumed ASCII or an ASCII-compatible character set, e.g. UTF-8.)

Source Link
ilkkachu
  • 148.1k
  • 16
  • 268
  • 441

for f in /etc/passwd; 

This is a bit silly as there's really no loop with just one value.

But the issue seems to be printing single quotes from awk. You could escape them in the shell, but you could also use backslash-escapes within awk to print them. \xHH is the character with numerical value HH (hex), so \x27 is '. So this would be one way to do it:

awk -F: -vID=$ID_minimum '$3>=1000 && $1!="nfsnobody" { printf "xfs_quota -x -c \x27limit bsoft=5g bhard=6g %s\x27 /home\n", $1}' /etc/passwd