To just extract first line:
Bash (replace tabs):
( IFS=$'\t' read -ra cols <file; echo "${cols[@]##*/}" )
- load first line of file into array, columns delimited by (any number of) tabs
- print array after stripping longest prefix that ends with a slash from each element
Bash (retain tabs):
(
shopt -s extglob
IFS= read -r cols
echo "${cols//+([!$'\t'])\/}"
) <file
Sed (replace tabs):
sed -E 's|[^ ]+/||g; y|\t| |; q' file
Sed (retain tabs):
sed -E 's|[^ ]+/||g; q' file
If the intention is to also retain the whole file as tsv:
Bash: append cat
after echo
in the "retain tabs" version:
(
shopt -s extglob
IFS= read -r cols
echo "${cols//+([!$'\t'])\/}"
cat
) <file
Sed: prefix s
command with 1
and elide the q
from "retain tabs" version:
sed -E '1s|[^ ]+/||g' file