#!/bin/bash
vars=(
"/foo/bar/baz/qux/file.txt"
"/a/b/c/d/e/f.txt"
"/1/2/3/4/5/6/7.txt"
)
lefttrim=3
# remove root and first element
((lefttrim += 2))
xargs -n1 <<<"${vars[*]}" |
printf "/%s\n" $(cut -d'/' -f"${lefttrim}"-)
To embed this project on your website, copy the following code and paste it into your website's HTML: