This article is published as a reply to the last few articles on the thoughtbot blog.
Some time or another during the project development you may wonder: «What files does my project include?» or «Why am I a Star Wars fan anyway?». This article will focus on the first question, leaving the second to your own reflection.
Any shell you might be using comes with a lot of useful tools. The one of interest today is ls
Here's the most simple example of its usage in a Rails project
sample_project $ ls README app db lib public test vendor Rakefile config doc log script tmp
As a little more complex example, you might want to get the list of your model files:
sample_project $ ls app/models/ comment.rb post.rb
Or, it even can do crazy stuff, like list all your model files AND controller files AND helper files! Now thats some useful magic, isn't it?
sample_project $ ls app/* app/controllers: application_controller.rb comments_controller.rb posts_controller.rb app/helpers: application_helper.rb comments_helper.rb posts_helper.rb app/models: comment.rb post.rb app/views: comments layouts posts
ls can do much. much more. Go check out the manual page here, you'll be amazed.
Note to Windows users: you also have a similar command, named dir.
Unbelievable! Thank you very much! I’ll know now!
[...] robots, we have a reply to your outstanding articles: A wonderful way to list your project files. Please read it carefully, you definitely will find something useful for you! Thanks to @labria for [...]
=)
find app -type d | sort | awk ‘{print “\n”$1″:”; system(”ls ” $1)}’
[...] This post was Twitted by calavera [...]
черный юмор пошел нынче в моду
поржал
Hi Labria,
Point well taken. “tail” is part of any developer’s toolbox.
I never had a formal computer science education and have picked up scraps of UNIX on the job.
The latest post wasn’t about tail so much as an application of it that I’ve found helpful recently while debugging some testing issues in Rails.
It’s probably basic, but I don’t feel the need to hold back what might seem basic to many readers if it comes in handy for a few others.
I try to keep such articles short so I’m not wasting anyone’s time, and in the theme of “this has been working for me; I hope it comes in handy for someone else, too.”
Thanks for reading.
A-A-A! моск взорван