360 Secure SkillHub
360 安全技能中心

Units

该 Skill 指导使用 bash 运行 GNU units 命令行工具进行单位换算与计算,支持基本换算、复合单位、温度等非线性单位、时间换算,以及通过 -o 控制小数位和使用单参数查询单位定义。依赖需自行通过 brew 或 apt 安装的 units 可执行文件,货币汇率为定义文件中的静态值。

asleep123
asleep123
热度 96.75
最近更新 2026-05-11 15:48:49
分类:效率依赖:代码执行应用场景:数据处理

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add units
Metadata
name
units
description
Perform unit conversions and calculations using GNU Units.
metadata
{"clawdbot":{"emoji":"📏","requires":{"bins":["units"]}}}

GNU Units Skill

Use GNU units to perform unit conversions and calculations via the command line. Can be installed using brew and apt under "units".

Usage

Use the bash tool to run the units command. Use the -t (terse) flag to get just the numeric result.

units -t 'from-unit' 'to-unit'

Examples

Basic Conversion:

units -t '10 kg' 'lbs'
# Output: 22.046226

Compound Units:

units -t '60 miles/hour' 'm/s'
# Output: 26.8224

Temperature (Non-linear): Temperature requires specific syntax: tempF(x), tempC(x), tempK(x).

units -t 'tempF(98.6)' 'tempC'
# Output: 37

Time:

units -t '2 weeks' 'seconds'

Rounding Output: To round to specific decimal places (e.g. 3 places), use -o "%.3f":

units -t -o "%.3f" '10 kg' 'lbs'
# Output: 22.046

Definition Lookup: To see what a unit definition is (without converting), omit the second argument (without -t is more verbose/useful for definitions):

units '1 acre'

Notes

  • Currency: units supports currency (USD, EUR, etc.), but exchange rates may be out of date as they are static in the definitions file.
  • Safety: Always quote your units to prevent shell expansion issues (e.g. units -t '1/2 inch' 'mm').