在Linux中,如何在每个输出行中列出一个文件名? [英] How do I list one filename per output line in Linux?

查看:253
本文介绍了在Linux中,如何在每个输出行中列出一个文件名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ls -a命令来获取目录中的文件名,但是输出在一行中.

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

赞:

.  ..  .bash_history  .ssh  updater_error_log.txt

我需要一个内置的替代方法来获取文件名,每个文件名都换行,如下所示:

I need a built-in alternative to get filenames, each on a new line, like this:

.  
..  
.bash_history  
.ssh  
updater_error_log.txt

推荐答案

使用-1选项(请注意,这是一个一个"数字,而不是小写字母"L"),如下所示:

Use the -1 option (note this is a "one" digit, not a lowercase letter "L"), like this:

ls -1a


但是,首先,请确保您的ls支持-1. GNU coreutils(安装在标准Linux系统上)和Solaris一样;但是如有疑问,请使用man lsls --help或查看文档.例如:


First, though, make sure your ls supports -1. GNU coreutils (installed on standard Linux systems) and Solaris do; but if in doubt, use man ls or ls --help or check the documentation. E.g.:

$ man ls
...
       -1     list one file per line.  Avoid '\n' with -q or -b

这篇关于在Linux中,如何在每个输出行中列出一个文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆