Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Use the UNIX redirect command to create lists UNIX
I read the hint about the export playlist feature in iTunes, and I want to share the way I create this list. I usually put all my MP3s in just one folder, so I use the Terminal to make a list using the UNIX "redirect output" flag, >, which redirect the standard output to a file (a textfile). To do this, you don't have to be a guru using the Terminal, just use cd /path/to/folder to navigate to the folder from which you want to make the list. Once you are there, type:
ls >> textfile.txt
If there are other sub-folders and you want to list their contents, too, you can use (but be careful, as it will list all sub-folders):
ls -R >> textfile.txt
The textfile is created in the current directory (unless you included a full path before textfile.txt). If the file already exists, it will make an append to that file (due to the use of two redirect symbols). However, if you use > instead of >>, the file will be overwriten instead of appended. This is an easy way of making a list of anything on Mac OS X ... or any Unix system.

[robg adds: Yes, this is a basic UNIX hint, but it's quite useful and I don't think we've covered the functionality before. You can use the redirect symbols on anything that dumps output to the screen -- ps -ax > running_stuff.txt will create a text file of the ps output, for example.]
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[5,589 views]  

Use the UNIX redirect command to create lists | 4 comments | Create New Account
Click here to return to the 'Use the UNIX redirect command to create lists' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use the UNIX redirect command to create lists
Authored by: cedmond on Jun 17, '03 01:33:22PM
This is a cool tip. In addition I would like to add that instead of using
ls -R >> textfile.txt
and getting all of the sub-directories you could list multiple directories after the 'ls' command. Such as:
ls ~/Pictures/ ~/Music/ >> textfile.txt
That way both directory listings would end up in the same text file.

[ Reply to This | # ]
Use the UNIX redirect command to create lists
Authored by: belette on Jun 18, '03 07:20:45AM
Or you could
sudo ls -R / >> hd.txt
and watch the file grow... ;-) Mine's 8.5 MB. Useful huh? (well, it could be, but now's just for fun)

[ Reply to This | # ]
Use the UNIX redirect command to create lists
Authored by: fivefifty on Jun 18, '03 03:23:59PM

Alternatively you can do

find . > list.txt


This will list each file with its entire path (sometimes useful).



[ Reply to This | # ]
Use the UNIX redirect command to create lists
Authored by: koelling on Jun 18, '03 03:57:21PM
for mpg123 (commandline mp3 player) you can add the --list list.txt flag where list.txt is a file with paths to your mp3s. I typically use the find command as it prints the whole path.

find ~/Music/ -iname "*.mp3" -print > list.txt

-iname
means case insensitive so this will find .mP3 .Mp3 .MP3 etc.

[ Reply to This | # ]