1

So I'm trying to direct a file to be created in another folder (let's say on my Desktop) from my bin directory. I made a text file with all the files in the directory using ls > textfile but this only creates the file in the bin directory, and so I'd like to know how I would direct it to the Desktop straight from bin?

Eliah Kagan
  • 117,780

3 Answers3

2

You specify a path:

ls > ~/Desktop/textfile
  • ~ is your home directory
  • / separates components in the path
  • so to point to something inside your home directory, say baz instead in bar inside foo, you do ~/foo/bar/baz.

Also see:

muru
  • 197,895
  • 55
  • 485
  • 740
1

Just put ls > path/to/your/desktop/textfile. A file named textfile will be created in your desktop.

Ron
  • 20,638
0

You can do it by

ls > ~/Desktop/textfile
Pilot6
  • 90,100
  • 91
  • 213
  • 324