Read & Display Single Line of a File

Sometimes when I’m troubleshooting a PHP error and a function is called in the debugger that gives me a line number of a file to look at, I want to know what that line says without opening up the file.  Using the command line, you can accomplish this in the following way:

head -n 96 filename.php | tail -n 1

This allows you to quickly display the 96th line of filename.php. Hope this helps someone like it has me.

Author: devnet

devnet has been a project manager for a Fortune 500 company, a Unix and Linux administrator, a Technical Writer, a System Analyst, and a Systems Engineer during his 20+ years working with Technology.

8 thoughts on “Read & Display Single Line of a File”

  1. Sweet Binny! There are always multiple ways to do things in Linux and it’s fantastic to be able to have so much versatility at your fingertips 🙂 Thanks for the extra tip 😀

  2. xargs -i -t -exec grep -i -w {} file_1 >>test < file_2

    This was meant to search for the contents of file_2 in file_1 and write the respective lines into file"test" . But instead it writes
    grep -i -w "string1" File_1
    grep -i -w "string2" File_1
    grep -i -w "string3" File_1
    to the standard output and creates an empty file "test"
    Any ideas why this doesn't work?
    Your help is very much appreciated

    Udo

  3. Hi,
    I am newly join in this site.This site is very useful to others.Anyone can join and post a profile for free but cannot respond to messages from members until they pay their membership fee. Paying users can view others' profiles and access communication services such as anonymous email, chat, webcam, a webzine, and blogging. Members can purchase higher membership levels for benefits such as higher search rankings. Members can broadcast their webcam publicly to each other. Chat room viewers can page the broadcasting member in an attempt to initiate a chat session.For more information please visit the link.
    =======================
    sharoo

    Adult Dating

Comments are closed.

Creative Commons License
Except where otherwise noted, the content on this site is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.