Skip to content

'df' prints number with 'K' suffix making field non-numeric #1

@fortran77

Description

@fortran77

In the following code at around line 634

# Check for enough space.
root_fs_avail=$(df /|grep -v Filesystem|awk '{print $4}')
if [ "$root_fs_avail" -lt $((swap_min + 358400)) ]; then
  root_fs_avail_h=$((root_fs_avail / 1024))
  log_fatal "Root filesystem only has $root_fs_avail_h MB available, which is too small."
  log_fatal "You'll either need to use the --minimal installation of add more space to '/'."
  return 3
fi

on some systems (e.g., newer CentOS 7) the df command may print a filesystem size with a 'K' suffix. On the next line, the 'if [ "$root_fs_avail" -lt ...] ...' then reports an error because '-lt' expects a numeric argument.

An easy fix would be to pipe df's output through sed -e 's/[^0-9]//g' thus deletng all non-numeric characters.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions