
- Kali Linux Tutorial
- Kali Linux - Home
- Installation & Configuration
- Information Gathering Tools
- Vulnerability Analyses Tools
- Kali Linux - Wireless Attacks
- Website Penetration Testing
- Kali Linux - Exploitation Tools
- Kali Linux - Forensics Tools
- Kali Linux - Social Engineering
- Kali Linux - Stressing Tools
- Kali Linux - Sniffing & Spoofing
- Kali Linux - Password Cracking Tools
- Kali Linux - Maintaining Access
- Kali Linux - Reverse Engineering
- Kali Linux - Reporting Tools
- Kali Linux Useful Resources
- Kali Linux - Quick Guide
- Kali Linux - Useful Resources
- Kali Linux - Discussion
How to list one filename per output line in Linux?
There are plenty of Linux utility commands present to print the list of all the files and folders that are present in the current directory. Most commonly used are the ls and the find command.
Let’s explore a simple example where we will make use of the ls command to list all the files and the folders present in a particular directory.
Command
ls
Output
api cluster docs LICENSE Makefile.generated_files pkg staging vendor build cmd go.mod LICENSES _output plugin
On Ubuntu, we get the output in the above format, where all the names of the files and the folders are written like this.
In order to print only the file names in a single line, line by line, we need to either make use of a flag with the ls command or append another command to it.
The first command that will allow us to list one filename per output file is shown below.
Command
ls | tr “” “
”
In the above command, we are using the tr command that is used for deleting or translating characters.
Output
api build CHANGELOG CHANGELOG.md cluster cmd code-of-conduct.md CONTRIBUTING.md docs go.mod go.sum hack LICENSE LICENSES ...
Another command that we can use is shown below.
Command
ls -a | cat
Output
api build CHANGELOG CHANGELOG.md cluster cmd code-of-conduct.md CONTRIBUTING.md docs go.mod go.sum hack LICENSE LICENSES ...
One more command is also there to print the filenames per line.
Command
ls -1
Output
api build CHANGELOG CHANGELOG.md cluster cmd code-of-conduct.md CONTRIBUTING.md docs go.mod go.sum hack LICENSE LICENSES ...
- Related Articles
- How to Change Terminal Output Color in Linux?
- How to replace string in a large one line, text file in Linux?
- How to display the complete text one word per line in C language?
- How to Save Command Output to a File in Linux?
- How to output colored text to a Linux terminal?
- How to match two strings that are present in one line with grep in Linux?
- How to Clear BASH Command Line History in Linux?
- How to swap two files in Linux command line?
- How to compare two sorted files line by line in the Linux system?
- How to list the directory content in Linux?
- Convert XLSX to CSV in Linux with Command Line in Linux
- How to list all users in a Linux group?
- How to read a Specific Line From a File in Linux?
- How to list running screen sessions on Linux?
- How to wrap each input line to fit in specified width in Linux?
