Towards the end of the Getting Help and Reading Documentation, we used
less to have the command line read through the contents of a text file. This can be helpful for times when you want to quickly glance at a text file. With all things, there is more than one way to do something; the command line is definitely no exception to this.
In this lesson, you will learn how to preview text files using the
tail commands, as well as pretty-printing. You may be familiar with the head and tail dataframe attributes in pandas, and these commands act the same exact way. You’ll be able to apply them in the terminal in much the same way you might when writing pandas code.
When learning about
tail, you will also learn about option-arguments, options that are passed as arguments to a command or commands. These arguments are also mentioned in Introduction to Command Line, but you will get a more in-depth explanation and further practice in this lesson.
You will also learn how to extract random lines from a file using the
shuf command. This can be helpful especially if the file is large, which is often the case in data science, since you may be manipulating files containing massive datasets.
- How to see the contents of files
- Different file types
- Text Files
- Head or Tail
- Counting Lines
- Pretty Printing
- File Sample
- Types of File
- Next Steps