How to add line number to a file? Commands Add comments Jan 022010 How to add line number to a file? Answer: The easiest way is to use the "sed" command sed = test.txt | sed 'N; s/^/ /; s/ *\(.\{6,\}\)\n/\1 /' Related posts: How to add line number to a text file? How to count the number of line in a file How to show line number in vi / vim? How to count the number of duplicated lines in a file How to find file by inode number Leave a Reply Cancel reply Name (required) E-mail (required) URI Your Comment You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>