New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Operating System General OS operation information and support

Proper dir from Terminal?


Post Reply New Thread Subscribe

 
Thread Tools
jlawn

 
Member Since: Jan 13, 2010
Posts: 17
jlawn is on a distinguished road

jlawn is offline
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!!
QUOTE Thanks
Dysfunction

 
Dysfunction's Avatar
 
Member Since: Mar 17, 2008
Location: Tucson, AZ
Posts: 6,620
Dysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant future
Mac Specs: 2008 and 2011 15" mbps, late 11 iMac, iPhone 4s, and too many ipods and other stuff

Dysfunction is offline
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

mike
This machine kills fascists
Got # ? phear the command line!
QUOTE Thanks
jlawn

 
Member Since: Jan 13, 2010
Posts: 17
jlawn is on a distinguished road

jlawn is offline
Major. Thanks a lot.
QUOTE Thanks
blairtechguy

 
Member Since: Sep 13, 2011
Location: Kentucky, USA
Posts: 100
blairtechguy will become famous soon enough
Mac Specs: Mac Pro 2 x 2.66 Xeon 6gb DDR2 1TB OSX Server

blairtechguy is offline
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

Blair Technology Group - Mac System Administrator
QUOTE Thanks
Dysfunction

 
Dysfunction's Avatar
 
Member Since: Mar 17, 2008
Location: Tucson, AZ
Posts: 6,620
Dysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant futureDysfunction has a brilliant future
Mac Specs: 2008 and 2011 15" mbps, late 11 iMac, iPhone 4s, and too many ipods and other stuff

Dysfunction is offline
Yeah, I always want file sizes and last modified dates. Habit, ya know.

mike
This machine kills fascists
Got # ? phear the command line!
QUOTE Thanks

Post Reply New Thread Subscribe


« Use applescript to batch find and copy .mov files to a new directory?! | How To Convert Files From Toshiba Camelio to Mac 10.4.11? »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Automatically save log files of terminal sessions Stubaan OS X - Apps and Games 3 04-02-2013 11:24 AM
Open a url in mac with blocking terminal tarun91 OS X - Operating System 4 05-18-2011 10:38 AM
Terminal Won't Open icefall5 OS X - Operating System 7 08-25-2010 08:26 AM
Terminal problems please help CliveO OS X - Operating System 6 03-20-2007 10:04 AM
Terminal Help rs2sensen OS X - Apps and Games 1 04-25-2005 10:52 PM

All times are GMT -4. The time now is 07:08 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?