
- 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 wrap each input line to fit in specified width in Linux?
To wraps a line in an input file to fit the specified width, we use the fold command in the Linux operating system.
The fold command is used to making a file with long lines more readable on a limited width output by performing a line wrap in the Linux system. Most Linux/Unix terminals default screen width of 80, and sometimes while reading files with long lines could be annoying.
The fold command wraps each input line to fit in specified width and allows the user to set the maximum length of a line. The fold command was inherited into the first version of POSIX.
Syntax
The general syntax of the fold command is as follows.
fold [OPTION]... [FILE]...
Brief description of options available in the fold command.
Sr.No. | Option & Description |
---|---|
1 | -b, --bytes Count bytes instead of columns |
2 | -c, --characters Count characters instead of count columns |
3 | -s, --spaces Break at spaces |
4 | -w, --width=WIDTH Use WIDTH columns instead of 80 |
5 | --help Display this help and exit |
6 | --version Output version information and exit |
By default, the fold command wraps the line up to 80 columns in the Linux system as shown below.
vikash@tutorialspoint− ~$ cat text.txt You can decide what you are going to think in any given situation. Your thoughts and feelings determine your actions and determine the results you get. It all starts with your thoughts – and I have found that inspirational words are a quick way to retune you’re thinking. vikash@tutorialspoint− ~$ fold text.txt You can decide what you are going to think in any given situation. Your thoughts and feelings determine your actions and determine the results you get. It all starts with your thoughts – and I have found that inspirational words are a quick way to retune you’re thinking.
To wrap the line of a file by specified width, we use the -w option with the fold command as shown below.
$ cat text.txt Hey, welcome to tutorialspoint... $ fold -w3 text.txt Hey , w Elc Ome To Tu Tor Spo int ...
We can also wrap the line from standard input instead of file by using the fold command in the Linux system as shown below.
$ fold -w5 Hey, welcome to Tutorialspoint... Hey, Welcome To Tutorialspoint...
To check more information about the fold command, we use the --help option with the fold command in the Linux operating system as shown below.
$ fold --help
To check version information of the fold command, we use the --version option with the fold command in the Linux operating system as shown below.
$ fold --version
- Related Articles
- How to Auto-Fit Column Width in Excel?
- How to set div width to fit content using CSS?
- How to Add a String After Each Line in a File in Linux?
- Make container shrink-to-fit child elements as they wrap in HTML
- How to wrap the text within the width of the window in JavaFX?
- How to get Linux console window width in Python?
- How to add best fit line/curve and formula in Excel
- How to remove sections from each line of files in the Linux system?\n
- How to adjust the width and height of an iframe to fit with content in it HTML?
- Flex container width when flex-flow is set to column wrap in HTML
- How to set a Matplotlib rectangle edge to outside of specified width?
- How to Clear BASH Command Line History in Linux?
- How to swap two files in Linux command line?
- How can we implement line wrap and word wrap text inside a JTextArea in Java?
- How to check if an input string contains a specified substring in JSP?
