Linux | 23. File Viewing with wc, cat, head, tail

Introduction

In this section, we will learn how to view files. In fact, we have used these commands multiple times in previous tutorials, so many of you may already be very familiar with them. In Windows, we know that both txt text files and word docx files have corresponding software to open and view them. However, in the Linux terminal, which lacks an interactive interface, we need to use commands for text viewing.

# Generate test file: for i in {1..100}; do echo $i >> test.txt done
# wc syntax: wc-options filename
# -l: display only the number of lines: wc -l test.txt
# -w: display only the number of words: wc -w test.txt
# wc -w test.txt wc -c test.txt
# cat syntax: cat-options filename
# -A: display special characters: cat -A test.txt
# -s: merge empty lines: cat -s test.copy.txt
# -b: display line numbers: cat -b test.txt
# cat redirection method 1: cat > filename Ctrl + D
# cat redirection method 2: cat << terminator > filename
# head syntax: head-options filename
# -n: number of lines to display: cat -n test.txt
# --line: same as above: cat --line 5 test.txt
# -number: same as above: cat -5 test.txt
# tail syntax: tail-options filename
# View lines 51 to 60 of the file: tail -50 test.txt | head -10

Video Tutorial

Simultaneously broadcast on Bilibili for easier viewing. You can directly access the original text at the end of this article:https://www.bilibili.com/video/BV1hT411F7r7?p=23

Learning Materials for This Section

To prevent everyone from being unable to access Baidu Cloud, I have uploaded the files to an Nginx server. You can download them by entering this URL in your browser:

http://biomamba.com:34080/free.download/%E8%B7%9FBiomamba%E4%B8%80%E8%B5%B7%E5%AD%A6Linux.zip

If the link is invalid, you can contact customer service at the end of the article to receive it~

Previous Reviews

Learn Linux with Biomamba | 1. Computer Hardware CompositionLinux | 2. Computer Software Composition and LinuxLinux | 3. Free Linux System – WSLLinux | 4. Free Linux System – Virtual MachineLinux | 5. Free Linux System – ServerLinux | 6. Command Line and Basic CommandsLinux | 7. Several Ways to Get Help with Linux CommandsLinux | 8. Linux File Directory SystemLinux | 9. Path Viewing and Switching: pwd, cd, ls CommandsLinux | 10. WildcardsLinux | 11. File Deletion: rm CommandLinux | 12. File Copy (cp) and Move (mv)Linux | 13. Concepts of Users and GroupsLinux | 14. User Management Commands (useradd, passwd, userdel, su)Linux | 15. File Permission Management: chown, chmodLinux | 16. ShortcutsLinux | 17. Output RedirectionLinux | 18. Pipe SymbolLinux | 19. File Search: find, locate, whichLinux | 20. Aliases: aliasLinux | 21. Soft Links and Hard Links: lnLinux | 22. (De)compression and MD5 ChecksumLinux | 23. File Viewing with wc, cat, head, tail

How to Contact Us

Linux | 23. File Viewing with wc, cat, head, tailLinux | 23. File Viewing with wc, cat, head, tailLeave a message to receive materials andan out-of-the-box single-cell analysis image atWeChat ID[Biomamba_zhushou], making it convenient for everyone to communicate at any time. We have also built a group chat matrix, and everyone is welcome to join the discussion.After reading these articles, you can addtips for beginners in bioinformaticsNo search, no voice

Students who already have contact information for the bioinformatics basedo not need to add again

Linux | 23. File Viewing with wc, cat, head, tail

Linux | 23. File Viewing with wc, cat, head, tailYour likes and views are taken seriously as appreciation

Leave a Comment