Hi All, This is my first post to centos-docs. I've read several months of archives, but, this may be too trivial. Re: http://wiki.centos.org/TipsAndTricks/EncryptedFilesystem/Scripts This line: FREE_SPACE=$(df -m $SECRET_PATH |grep / | awk '{ print $4 }') gave me a problem due to line wrapping in df. For example: $ df -m /home/ja/verify/ Filesystem 1M-blocks Used Available Use% Mounted on /dev/mapper/VolGroup00-LogVol00 589333 289168 269746 52% / So, $4 is 52% rather than 269746. The '/dev/mapper/VolGroup00-LogVol00' term is from a fresh install, so, perhaps others have this same name. This change worked for me: FREE_SPACE=$(${DF} -m ${PATH} | ${GREP} / \ | ${TR} "\n" ' ' | ${TR} -s ' ' | ${CUT} -d' ' -f4) Note the reformating onto 1 line with TR. The remainder could be what I have, the original awk statement, or whatever. Thanks for your consideration. JIm
Maybe the df manual can help you: -P, --portability use the POSIX output format On 09/26/2010 01:02 AM, Jim Angstadt wrote:> Hi All, > > This is my first post to centos-docs. I've read several months of > archives, but, this may be too trivial. > > Re: http://wiki.centos.org/TipsAndTricks/EncryptedFilesystem/Scripts > > This line: > > FREE_SPACE=$(df -m $SECRET_PATH |grep / | awk '{ print $4 }') > > gave me a problem due to line wrapping in df. For example: > > $ df -m /home/ja/verify/ > Filesystem 1M-blocks Used Available Use% Mounted on > /dev/mapper/VolGroup00-LogVol00 > 589333 289168 269746 52% / > > So, $4 is 52% rather than 269746. > > The '/dev/mapper/VolGroup00-LogVol00' term is from a fresh install, > so, perhaps others have this same name. > > This change worked for me: > FREE_SPACE=$(${DF} -m ${PATH} | ${GREP} / \ > | ${TR} "\n" ' ' | ${TR} -s ' ' | ${CUT} -d' ' -f4) > > Note the reformating onto 1 line with TR. The remainder could be what > I have, the original awk statement, or whatever. Thanks for your > consideration. > > JIm > _______________________________________________ > CentOS-docs mailing list > CentOS-docs at centos.org > http://lists.centos.org/mailman/listinfo/centos-docs >-------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 262 bytes Desc: OpenPGP digital signature URL: <http://lists.centos.org/pipermail/centos-docs/attachments/20100926/f7a05fe7/attachment-0004.sig>
On Sat, Sep 25, 2010 at 4:07 PM, Laszlo Fekete <blackluck at ktk.bme.hu> wrote:> Maybe the df manual can help you: > > ?-P, --portability ? ? use the POSIX output formatThanks for you reply. Yes, that works also. Do you think that the page should be changed, or is this too trivial? Jim
Am 26.09.10 01:02, schrieb Jim Angstadt:> gave me a problem due to line wrapping in df. For example: > > $ df -m /home/ja/verify/ > Filesystem 1M-blocks Used Available Use% Mounted on > /dev/mapper/VolGroup00-LogVol00 > 589333 289168 269746 52% / > > So, $4 is 52% rather than 269746.ARGH. IDIOTS. Changed it to df -P -m in the script. Thanks for finding that. Ralph