Proper dir from Terminal?

Joined
Jan 13, 2010
Messages
17
Reaction score
0
Points
1
Proper /dir listing from Terminal?

When I generate a directory listing w/ a PC, i use cmd: "dir /b/s" and this will generate a list of my files with each file's path in front of it (ex: rootfolder\subfolder\file.txt). I can easily manipulate this in excel to upload files to my database with a directory command.

How can I get the same results from Terminal? I have been using "ls -lR", and getting a list, however it only lists the parent folder once, then all file names beneath... then the next parent folder name, all file names, etc. I need to see the individual path in front of each file name that is generated.

This has been stunting my progress for a while now, and any help is greatly appreciated!!
 
Joined
Mar 17, 2008
Messages
6,879
Reaction score
191
Points
63
Location
Tucson, AZ
Your Mac's Specs
Way... way too many specs to list.
du -ah will do this (with human readable file sizes)

example output:
Code:
mikeMBP-2:Installs mike$ du -ah
 16K	./.DS_Store
2.0G	./adobepe9.dmg
 91M	./CEP-3.0-WacomEdition6-3.110.dmg
264M	./ColorMunkiDisplay101.zip
 80M	./lensprofile_creator_p3_mac_042711.dmg
1.0M	./lensprofile_downloader_p3_102510.air
 16K	./Lion installs/.DS_Store
3.5G	./Lion installs/InstallESD.dmg
3.5G	./Lion installs
1.5M	./LionTweaks.zip
7.0M	./LRMogrify2.lrplugin.zip
10.0M	./onOne_PerfectPresets_LR.dmg
 69M	./PhotoTools_2.6.3_Free.pkg.zip
120K	./Resuminator.zip
 61M	./sketch_pad_de_fr_en.dmg
2.9M	./SuperDuper!.dmg
8.0K	./Wacom_Brushes_3/.DS_Store
 12K	./Wacom_Brushes_3/Wacom Brushes 3 Readme.rtf
312K	./Wacom_Brushes_3/Wacom Brushes 3.abr
332K	./Wacom_Brushes_3
6.1G	.

There are probably a thousand ways to pull this off, it is Unix after all, but du's the easiest IMO.

This also works well.

Code:
mikeMBP-2:Installs mike$ find . -type d -exec ls -lR  {} ';'
total 5414304
-rw-r--r--@ 1 mike  staff    95862481 Feb 16  2011 CEP-3.0-WacomEdition6-3.110.dmg
-rw-r--r--@ 1 mike  staff   277045436 Sep 26 09:37 ColorMunkiDisplay101.zip
-rw-------@ 1 mike  staff     7306367 Aug 27 20:45 LRMogrify2.lrplugin.zip
drwxr-xr-x  4 mike  staff         136 Dec  1 20:11 Lion installs
-rw-------@ 1 mike  staff     1562599 Sep 26 20:38 LionTweaks.zip
-rw-------@ 1 mike  staff    72755047 Aug  7 23:20 PhotoTools_2.6.3_Free.pkg.zip
-rw-------@ 1 mike  staff      121243 Sep 26 19:21 Resuminator.zip
-rw-r--r--@ 1 mike  staff     3036322 Aug 16 19:12 SuperDuper!.dmg
drwx------@ 5 mike  staff         170 Aug  7 21:49 Wacom_Brushes_3
-rw-r--r--@ 1 mike  staff  2154935181 Feb 16  2011 adobepe9.dmg
-rw-r--r--@ 1 mike  staff    83972878 Aug 23 22:27 lensprofile_creator_p3_mac_042711.dmg
-rw-r--r--@ 1 mike  staff     1048833 Aug 23 22:27 lensprofile_downloader_p3_102510.air
-rw-r--r--@ 1 mike  staff    10485760 Aug  8 09:07 onOne_PerfectPresets_LR.dmg
-rw-r--r--@ 1 mike  staff    63967232 Mar 20  2009 sketch_pad_de_fr_en.dmg

./Lion installs:
total 7310568
-rw-r--r--@ 1 mike  staff  3743009943 Jul 20 06:37 InstallESD.dmg

./Wacom_Brushes_3:
total 648
-rwxr-xr-x  1 mike  staff    8453 Jun  8  2007 Wacom Brushes 3 Readme.rtf
-rwxr-xr-x@ 1 mike  staff  317083 Jun 12  2007 Wacom Brushes 3.abr
total 7310568
-rw-r--r--@ 1 mike  staff  3743009943 Jul 20 06:37 InstallESD.dmg
total 648
-rwxr-xr-x  1 mike  staff    8453 Jun  8  2007 Wacom Brushes 3 Readme.rtf
-rwxr-xr-x@ 1 mike  staff  317083 Jun 12  2007 Wacom Brushes 3.abr
 
Joined
Sep 13, 2011
Messages
100
Reaction score
2
Points
18
Location
Kentucky, USA
Your Mac's Specs
Mac Pro 2 x 2.66 Xeon 6gb DDR2 1TB OSX Server
find can do the job in real simple without having to pipe outputs through awk if you are just need filepaths.

Code:
$ find .
.
./.gitignore
./app
./app/assets
./app/assets/images
./app/assets/images/rails.png
./app/assets/javascripts
./app/assets/javascripts/application.js
./app/assets/javascripts/home.js.coffee
./app/assets/javascripts/posts.js.coffee
./app/assets/stylesheets
./app/assets/stylesheets/application.css
./app/assets/stylesheets/home.css.scss
./app/assets/stylesheets/posts.css.scss
./app/assets/stylesheets/scaffolds.css.scss
./app/controllers
./app/controllers/application_controller.rb
./app/controllers/home_controller.rb
./app/controllers/posts_controller.rb
./app/helpers
 
Joined
Mar 17, 2008
Messages
6,879
Reaction score
191
Points
63
Location
Tucson, AZ
Your Mac's Specs
Way... way too many specs to list.
Yeah, I always want file sizes and last modified dates. Habit, ya know. :)
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top