cutting a string into several lines in bash cutting a string into several lines in bash bash bash

cutting a string into several lines in bash


This should do the trick

pwd | tr '/' '\n'

If you don't want an empty line in the beginning (due to the initial /) you could do

pwd | cut -b2- | tr '/' '\n'

Example:

#aioobe@r60:~/tmp/files$ pwd/home/aioobe/tmp/files#aioobe@r60:~/tmp/files$ pwd | cut -b2- | tr '/' '\n'homeaioobetmpfiles


You can try:

pwd | tr '/' '\n'


This is how you would accomplish what you set out to do (using ANSI-C quoting):

pwd | cut -f 1- -d\/ --output-delimiter=$'\n'