Linux fold command: limit file column width to show file contents
Linux fold command Function Description
Using the fold command, you can read the content from the specified file, add the columns that exceed the limited column width to the incremental characters, and then output to the standard output device.
Linux fold command Syntax
fold [Option] [File]
The meaning of each option in the command is shown in the table:
Option | Description |
---|---|
-c | Total number of characters |
-s | Use space characters as column breaks |
-b | Count width by bytes. Default value is count by column |
-w<width> |
Use the specified width to display, instead of the default 80 |
Linux fold command Demo
Display the contents of the /root/apidemos.com.txt file
[root@rhel ~]# fold /root/apidemos.com.txt
Output:
Display the contents of the /root/apidemos.com.txt file with a width of 10 characters
[root@rhel ~]# fold -w 10 /root/apidemos.com.txt
Output: