![]() You can specify the number of lines printed using the -n flag: head -n 50 myfile.txtįor the tail command, you can add a + before the number of lines, which will instead print all lines starting from that line number to the end of the file. Tail allows you to view the bottom of the file - by default the last 10 lines of the file are printed to the screen: tail myfile.txt Head allows you to view the top of the file - by default the first 10 lines of the file are printed to the screen: head myfile.txt Sometimes you might not want to view a whole file, but rather just a small portion to have a glimpse at what the file looks like. Multiple flags can be used together: cat -nv myfile.txtĬheck out the manual for other flags that might be useful: man cat To view all non-printing characters, use the -v flag: cat -v myfile.txt ![]() To count the number the lines that are printed with cat use the -n flag: cat -n myfile.txt Multiple files can be printed one after the other, which can be useful for joining multiple files together: cat file1.txt file2.txt > myjoinedfile.txt To get just the number of characters, use the -c flag: wc -c myfile.txtĬat will print the contents of a file to the screen: cat myfile.txt ![]() To get just the number of words, use the -w flag: wc -w myfile.txt To get just the number of lines, use the -l flag: wc -l myfile.txt The wc command can be used to count the number of lines, words and characters in a file: wc myfile.txt If you wish to save the results, you will need to redirect the output to a file (unless otherwise stated). Note: The default behaviour for all of these commands is to print the results to the screen.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |