-1

How can I get a list of all files in the current directory and store that to a file named mycurrent using the command-line?

0

1 Answer 1

1

Perhaps the easiest method is to simple run the following command from the current directory:

ls > mycurrent

There are many options available to the ls command to tailor the output to your specific needs.

2
  • 1
    Perhaps this is just a matter of opinion but it might be worth mentioning that by renaming "mycurrent" to "mycurrent.txt" in the command you can make it not only clear that file in question is a text file but also make it less of a hassle to open the file if it is ever sent to a different OS.
    – Allu2
    Jun 17, 2016 at 1:25
  • Even less of a hassle will be if you translate newline to carriage return + newline. There's no requirement for that, however, and we're not sending anything to a different OS. It's only a "what if" case. Bigger issue at hand is potentially bad filenames, and parsing of ls, which should never be done. Jun 17, 2016 at 2:05

Not the answer you're looking for? Browse other questions tagged .