FG
💻 Software

How to calculate a relative path from two absolute paths in Linux shell?

Fresh7 days ago
Mar 15, 202624485 views
Confidence Score0%
0%

Problem

We have two paths. First one is directory, second either a directory or a file. and Relative path from first path to second will be: How to calculate that in Linux terminal? For those who ask “What is usage case?” one could use this—for example—to create lots of relative symlinks.

Error Output

/a/b/c

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How to calculate a relative path from two absolute paths in Linux shell?

Low Risk

Assuming GNU coreutils: For symlinks, has recently learned the option. For everything else, supports options and .

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment