Skip to main content
Tweeted twitter.com/StackUnix/status/1174201494817660929
added 15 characters in body
Source Link
terdon
  • 252.7k
  • 69
  • 481
  • 719

I have been trying to find the answer to this question for awhilea while. I am writing a quick script to run a command based on output from awk.

ID_minimum=1000 for f in /etc/passwd; do  awk -F: -vID=$ID_minimum '$3>=1000 && $1!="nfsnobody" { print "xfs_quota -x -c 'limit bsoft=5g bhard=6g $1' /home "}' $f; done 

The problems are that the -c-c argument takes a command in single quotes and I can't figure out how to properly escape that and also that $1$1 doesn't expand into the username.

essentiallyEssentially I am just trying to get it to output:

xfs_quota -x -c 'limit bsoft=5g bhard=6g userone' /home xfs_quota -x -c 'limit bsoft=5g bhard=6g usertwo' /home 

etc...

I have been trying to find the answer to this question for awhile. I am writing a quick script to run a command based on output from awk.

ID_minimum=1000 for f in /etc/passwd; do awk -F: -vID=$ID_minimum '$3>=1000 && $1!="nfsnobody" { print "xfs_quota -x -c 'limit bsoft=5g bhard=6g $1' /home "}' $f; done 

The problems are that the -c argument takes a command in single quotes and I can't figure out how to properly escape that and also that $1 doesn't expand into the username.

essentially I am just trying to get it to output:

xfs_quota -x -c 'limit bsoft=5g bhard=6g userone' /home xfs_quota -x -c 'limit bsoft=5g bhard=6g usertwo' /home 

etc...

I have been trying to find the answer to this question for a while. I am writing a quick script to run a command based on output from awk.

ID_minimum=1000 for f in /etc/passwd; do  awk -F: -vID=$ID_minimum '$3>=1000 && $1!="nfsnobody" { print "xfs_quota -x -c 'limit bsoft=5g bhard=6g $1' /home "}' $f; done 

The problems are that the -c argument takes a command in single quotes and I can't figure out how to properly escape that and also that $1 doesn't expand into the username.

Essentially I am just trying to get it to output:

xfs_quota -x -c 'limit bsoft=5g bhard=6g userone' /home xfs_quota -x -c 'limit bsoft=5g bhard=6g usertwo' /home 

etc...

Became Hot Network Question
added 8 characters in body
Source Link
jesse_b
  • 41.6k
  • 14
  • 109
  • 163

I have been trying to find the answer to this question for awhile. I am writing a quick script to run a command based on output from awk.

ID_minimum=1000 for f in /etc/passwd; do awk -F: -vID=$ID_minimum '$3>=1000 && $1!="nfsnobody" { print "xfs_quota -x -c 'limit bsoft=5g bhard=6g $1' /home "}' $f; done 

The problems are that the -c argument takes a command in single quotes and I can't figure out how to properly escape that and also that $1 doesn't expand into the username.

essentially I am just trying to get it to output:

xfs_quota -x -c 'limit bsoft=5g bhard=6g userone' /home xfs_quota -x -c 'limit bsoft=5g bhard=6g usertwo' /home

xfs_quota -x -c 'limit bsoft=5g bhard=6g userone' /home xfs_quota -x -c 'limit bsoft=5g bhard=6g usertwo' /home 

etc...

I have been trying to find the answer to this question for awhile. I am writing a quick script to run a command based on output from awk.

ID_minimum=1000 for f in /etc/passwd; do awk -F: -vID=$ID_minimum '$3>=1000 && $1!="nfsnobody" { print "xfs_quota -x -c 'limit bsoft=5g bhard=6g $1' /home "}' $f; done 

The problems are that the -c argument takes a command in single quotes and I can't figure out how to properly escape that and also that $1 doesn't expand into the username.

essentially I am just trying to get it to output:

xfs_quota -x -c 'limit bsoft=5g bhard=6g userone' /home xfs_quota -x -c 'limit bsoft=5g bhard=6g usertwo' /home

etc...

I have been trying to find the answer to this question for awhile. I am writing a quick script to run a command based on output from awk.

ID_minimum=1000 for f in /etc/passwd; do awk -F: -vID=$ID_minimum '$3>=1000 && $1!="nfsnobody" { print "xfs_quota -x -c 'limit bsoft=5g bhard=6g $1' /home "}' $f; done 

The problems are that the -c argument takes a command in single quotes and I can't figure out how to properly escape that and also that $1 doesn't expand into the username.

essentially I am just trying to get it to output:

xfs_quota -x -c 'limit bsoft=5g bhard=6g userone' /home xfs_quota -x -c 'limit bsoft=5g bhard=6g usertwo' /home 

etc...

Source Link
ZCT
  • 209
  • 2
  • 4

Bash awk command with quotes

I have been trying to find the answer to this question for awhile. I am writing a quick script to run a command based on output from awk.

ID_minimum=1000 for f in /etc/passwd; do awk -F: -vID=$ID_minimum '$3>=1000 && $1!="nfsnobody" { print "xfs_quota -x -c 'limit bsoft=5g bhard=6g $1' /home "}' $f; done 

The problems are that the -c argument takes a command in single quotes and I can't figure out how to properly escape that and also that $1 doesn't expand into the username.

essentially I am just trying to get it to output:

xfs_quota -x -c 'limit bsoft=5g bhard=6g userone' /home xfs_quota -x -c 'limit bsoft=5g bhard=6g usertwo' /home

etc...