There are many ways to display a file with a row number to display a row number. Some programs are even short. For example, you can use an awk to implement: 1awk '{print NR ":" $0}' <inputfile. Similarly, in some Unix versions, the cat command has the-n option, or more (less, pg) can also be used to display row numbers. However, there are some Unix versions, and none of them are available. At this time, the following simple script can be used: 01 #! /Bin/sh02 03 # numberlines. sh -- the effect is equivalent to the cat-n command 04 05for filename06do07 linecount = "1" 08 while read line09 do10 echo "$ {linecount }: $ line "11 linecount =" $ ($ linecount + 1) "12 done <$ filename13done14 15 exit 0 This script can accept any number of files as input, however, it cannot be provided with inputs through pipelines. Of course, you can modify the program if necessary. Test Script: 1 $ numberlines text.snippet.txt 21: Perhaps one of the most valuable uses of shell scripts is to fix32: your particle flavor of Unix and make it more like other flavors, 43: to bring your commands into conformance or to increase consistency54: Unsupported SS different systems. the outsider view of Unix suggests a65: nice, uniform command-line experience, helped along by the existence76: of and comp Liance with the POSIX standards for Unix. but anyone who 's87: ever touched more than one computer knows how much they can vary98: within these broad parameters. if you have a file that marks the travel number, you can reverse the file: 1cat-n filename | sort-nr | when will the command above cut-c8 be useful? A common problem is that when you want to display a log file.