The extra
Linux command is a formidable software that permits customers to view textual content recordsdata within the terminal one display screen at a time. It’s an crucial command for any individual who often works with huge textual content recordsdata. Through breaking down the content material into manageable chunks, the extra
command complements clarity and navigation, making it more straightforward to investigate and perceive the knowledge inside the record.
Very similar to the extra
command, the much less
command provides further flexibility and contours, equivalent to backward navigation. Each instructions are often used for viewing log recordsdata, configuration recordsdata, and different textual content paperwork inside the Linux atmosphere. For the ones having a look to mix instructions for extra complicated duties, the extra
command can be utilized along equipment like grep
to seek for explicit patterns inside of a record.
The right way to Use extra
1. Viewing a Record
Syntax: extra [filename]
Clarification: Presentations the content material of a record one display screen at a time.
Instance: extra myfile.txt
Output:
That is line 1 That is line 2 --Extra--(10%)
The output presentations the primary few strains of myfile.txt
and signifies that 10% of the record has been displayed. Urgent the spacebar will display the following display screen of content material.
2. Viewing More than one Information
Syntax: extra file1 file2 ...
Clarification: Presentations the contents of a couple of recordsdata sequentially.
Instance: extra file1.txt file2.txt
Output:
Contents of file1.txt --Extra--(record 1 of two)
The output presentations the contents of file1.txt
and signifies that it’s the primary of 2 recordsdata. You’ll be able to navigate throughout the recordsdata the usage of the similar controls as viewing a unmarried record.
3. Looking out Inside of a Record
Syntax: extra [filename], then sort /trend to go looking.
Clarification: Lets in looking for a particular trend inside the record.
Instance: extra myfile.txt, then sort /line 3
Output:
That is line 3 --Extra--(20%)
After opening myfile.txt
with extra
, typing /line 3
searches for the textual content line 3
and shows the corresponding line, indicating that 20% of the record has been displayed.
4. Viewing a Record with Line Numbers
Syntax: extra -n [filename]
Clarification: Presentations the content material of a record with line numbers.
Instance: extra -n myfile.txt
Output:
1 That is line 1 2 That is line 2 --Extra--(10%)
The output presentations the primary few strains of myfile.txt
with line numbers, and signifies that 10% of the record has been displayed.
5. Viewing a Record with a Particular Selection of Strains according to Display
Syntax: extra -num [filename]
Clarification: Presentations the content material of a record with a particular selection of strains according to display screen.
Instance: extra -5 myfile.txt
Output:
That is line 1 That is line 2 That is line 3 That is line 4 That is line 5 --Extra--(25%)
The output presentations the primary 5 strains of myfile.txt
and signifies that 25% of the record has been displayed.
6. Piping Output to “extra”
Syntax: [command] | extra
Clarification: Pipes the output of some other command thru extra
to view it one display screen at a time.
Instance: ls -l | extra
Output:
-rw-r--r-- 1 consumer consumer 1234 Jan 1 12:00 file1.txt -rw-r--r-- 1 consumer consumer 5678 Jan 1 12:01 file2.txt --Extra--
The output presentations the lengthy list of recordsdata within the present listing, exhibiting them one display screen at a time. The --Extra--
recommended signifies there’s extra content material to view.
7. Viewing a Record and Exiting at the First Fit of a Trend
Syntax: extra +/trend [filename]
Clarification: Opens the record and jumps without delay to the primary incidence of the required trend.
Instance: extra +/line3 myfile.txt
Output:
That is line 3 That is line 4 --Extra--(20%)
The output presentations the content material ranging from the primary incidence of line3
in myfile.txt
, indicating that 20% of the record has been displayed.
Extra Linux instructions:
Listing Operations | rmdir · cd · pwd |
Record Operations | cat · cp · dd · much less · ls · mkdir · mv · tail · tar · zip |
Record Device Operations | chown · mkfs |
Networking | ping · curl · wget · iptables |
Seek and Textual content Processing | in finding · grep · sed · whatis |
Device Data and Control | env · historical past · most sensible · who |
Consumer and Consultation Control | display screen · su · sudo |
The submit The right way to Use the ‘extra’ Command in Linux gave the impression first on Hongkiat.
WordPress Website Development Source: https://www.hongkiat.com/blog/linux-command-more/