Echo one line from a file in Linux
Posted:Sunday, June 28th, 2015
Last modified:Sunday, June 28th, 2015
Output a specific line from a text file with awk.
awk 'NR==1' filename
In this example we have mysql dump file with a syntax error on line 15588. That's a big file, so we don't want to fuss about in a text editor looking for it.
$ awk 'NR==15588' mydatabase.sql Warning: Using a password on the command line interface can be insecure.
Reading the offending line directly shows us the Drupal Backup and Migrate module is causing mysql warnings to be written to the dump file, which causes the fatal import errors.
Available Wiki Topics
The operator of this site makes no claims, promises, or guarantees of the accuracy, completeness, originality, uniqueness, or even general adequacy of the contents herein and expressly disclaims liability for errors and omissions in the contents of this website.