Home > Article > System Tutorial > How to read the length of txt file using linux command
In Linux systems, the txt file length (in bytes) can be read through the wc -c command. The steps are as follows: open a terminal; navigate to the file directory; use the command wc -c filename.txt; view the number of bytes in the wc command output. For example, wc -c myfile.txt outputs 1024 indicating that the file length is 1024 bytes.
How to read the length of txt file in Linux
In Linux system, you can read it through the command line txt file length. The following steps describe how to do this:
1. Open a terminal
2. Navigate to the file directory
<code class="shell">cd /path/to/directory/</code>
3. Use wc command
<code class="shell">wc -c filename.txt</code>
For example:
<code class="shell">wc -c myfile.txt</code>
4. View the length
Example:
If the length of the myfile.txt file is 1024 bytes, the output of the wc command is as follows:
<code class="shell">1024 myfile.txt</code>
5. Other options
#The wc command also provides other options that provide more detailed information. For example:
-l
: Only the number of rows is displayed. -w
: Only the number of words is displayed. -L
: Display the length of the longest line. The above is the detailed content of How to read the length of txt file using linux command. For more information, please follow other related articles on the PHP Chinese website!