cutting a string into several lines in bash

I want to take the path of the local directory and put each directory on the path in a different line. I've tried to do it using cut:

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

but it doesn't change the '/'s into EOL, but puts n's instead. What am I doing wrong?

Answers


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'
home
aioobe
tmp
files

Need Your Help

Rails how to create an initializer inside a gem

ruby-on-rails-3 gem initializer

I am trying to build a gem in Rails 3 and inside it i am trying to pass an initializer:

Image segmentation in C# (line segmentation and character segmentation)

c# .net image-processing image-segmentation

i was looking for an example for segmentation based on line and characters. but i couldn't find any helpful resource. if someone can provide me an example how to do it, it would be nice..

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.