Here I am, new and wet behind the ears to Bash/Shell Scripting.
Basically I am needing to know how to utilize sed in this instance on one of two very basic scripts. The intention is to retrieve disk usage info based on username/domain name.
You might be asking why two of the same scripts?
Given I work with many username/domains, the default domain_usage will be be overwritten into to domain_usage_tmp as and when username/domain changes. I have tried using sed to substitute, which has not provided the intended results:
sed 's/username/x/g' 's/domain/x/g' /scripts/domain_usage_tmp
Provide me with knowledge and wisdom :-)
CodePudding user response:
Perhaps you forget to use the -i
option:
man sed
...
-i[SUFFIX], --in-place[=SUFFIX]
edit files in place (makes backup if SUFFIX supplied)
sed -i 's/username/x/g' 's/domain/x/g' /scripts/domain_usage_tmp
CodePudding user response:
Thanks for the swift reply ramsay & jack_skellington
I've received stnd error:
sed: can't read s/domain/DOMAIN NAME HERE/g: No such file or directory
The domain directory does indeed exist btw, so I'm unsure why I've gotten the error.
@KamilCuk
#!/bin/bash #This script is intended to retrieve disk usage on home dir & vmail
#Retrieve home dir usage. du -hs /home/x/
du -hs /var/vmail/domain/
du -hs /home/x/*
du -hs /var/vmail/domain/*