Alex Rivera | Logout

Replacing / with TAB using sed

Asked 2011-06-15T19:43:03.697
26

I need to replace a slash character with a tab to I can extract a directory name using awk.

/path/to/some/USEFUL_INFORMATION/in/some/path

I tried doing this, but all it does is put a "t" at the from of my output.

sed -e 's/\//\t/g' filename

Any help would be appreciated.

Edit
Report

1 Answer

0

Use + as delimiters sed -e 's+/+\t+g'

echo 'path/to/something' | sed -e 's+/+\t+g'

// path     to     something

Edit: a simpler way to extract the path of a file:

dirname /path/to/file.txt
#output /path/to
answered 2011-06-15T19:46:46.397

Your Answer