Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
  • Categories

    • Bits
    • Bytes
    • Chart
    • Conversions
    • Core
    • Database
    • Dataframe
    • Dataframe Or Lazyframe
    • Date
    • Debug
    • Default
    • Env
    • Experimental
    • Expression
    • Filesystem
    • Filters
    • Formats
    • Generators
    • Hash
    • History
    • Lazyframe
    • Math
    • Misc
    • Network
    • Path
    • Platform
    • Plugin
    • Prompt
    • Random
    • Removed
    • Shells
    • Strings
    • System
    • Viewers

path relative-to for path

Express a path as relative to another path.

Signature

> path relative-to {flags} (path)

Parameters

  • path: Parent shared with the input path.

Input/output types:

inputoutput
stringstring
list<string>list<string>

Examples

Find a relative path from two absolute paths

> '/home/viking' | path relative-to '/home'
viking

Find a relative path from absolute paths in list

> [ /home/viking, /home/spam ] | path relative-to '/home'
╭───┬────────╮
│ 0 │ viking │
│ 1 │ spam   │
╰───┴────────╯

Find a relative path from two relative paths

> 'eggs/bacon/sausage/spam' | path relative-to 'eggs/bacon/sausage'
spam

Notes

Can be used only when the input and the argument paths are either both absolute or both relative. The argument path needs to be a parent of the input path.