I am trying to include this
du -s *|awk '{ if ($1 > 3000) print }'
in a shell script, but I want to parameterize the 3000. However, since the $1
is already being used, I'm not sure what to do. This was a total failure:
size=$1
du -s *|awk '{ if ($1 > $size) print }'
How can I pass a parameter in place of 3000 in the first script above?
when passing shell variables to awk, try to use the -v
option of awk as much as possible. This will be "cleaner" than having quotes all around
size="$1"
du -s *| awk -v size="$size" '$1>size'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With