cutting a string into several lines in bash

This should do the trick

pwd | tr "https://stackoverflow.com/" '\n'

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

pwd | cut -b2- | tr "https://stackoverflow.com/" '\n'

Example:

#aioobe@r60:~/tmp/files$ pwd
/home/aioobe/tmp/files
#aioobe@r60:~/tmp/files$ pwd | cut -b2- | tr "https://stackoverflow.com/" '\n'
home
aioobe
tmp
files

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)