-1

I want to split this line

/home/edwprod/abortive_visit/bin/abortive_proc_call.ksh

to

/edwprod/abortive_visit/bin/abortive_proc_call.ksh

Can I use sed or awk command for this?

jww
  • 97,681
  • 90
  • 411
  • 885
  • Possible duplicate of [Remove first directory components from path of file](https://stackoverflow.com/questions/5311956/remove-first-directory-components-from-path-of-file) – Tsyvarev Feb 15 '19 at 12:31

2 Answers2

0
echo '/home/edwprod/abortive_visit/bin/abortive_proc_call.ksh' | sed  's@^/[^/]\+@@'

Explanatory words: using sed's replace function, we redefine the separator, which is commonly /, to @, saving us the escaping of slashes within the string. We anchor the regex at the beginning of line ^, and replace the first slash, followed by any non-slash, with nothing, thus removing the first element of the path (not the root, btw).

tink
  • 14,342
  • 4
  • 46
  • 50
0

you don't need awk or sed , just try this

echo -n "/"; echo "/home/edwprod/abortive_visit/bin/abortive_proc_call.ksh" |cut -f3-6 -d/
Mike Bastoon
  • 114
  • 7