How do I list one filename per output line in Linux?

前端 未结 7 1886
挽巷
挽巷 2020-12-22 15:24

I\'m using ls -a command to get the file names in a directory, but the output is in a single line.

Like this:

.  ..  .bash_history  .ss         


        
7条回答
  •  旧巷少年郎
    2020-12-22 16:08

    Yes, you can easily make ls output one filename per line:

    ls -a | cat
    

    Explanation: The command ls senses if the output is to a terminal or to a file or pipe and adjusts accordingly.

    So, if you pipe ls -a to python it should work without any special measures.

提交回复
热议问题