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.

This content is published under the Attribution-Noncommercial-Share Alike 3.0 Unported license.

About

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

  • http://lindesk.com/ Binny V A

    This command will work as well…
    sed -n ’96p’ filename.txt

  • http://linux-blog.org devnet

    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 :D

  • http://it.jessupblogs.com Jeff

    Thanks for your help. Exactly what I was looking for!

  • http://intensedebate.com/people/devnet devnet

    Jeff,

    You bet! Glad it helped out :)

  • Udo

    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

  • sharoosunidhi

    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

  • rlw

    hooray! exactly what i needed. love it when that happens.

  • Ronald Muller

    sed ’96!d’ filename.txt