*BSD News Article 74480


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!munnari.OZ.AU!news.mel.connect.com.au!news.mira.net.au!vic.news.telstra.net!act.news.telstra.net!psgrain!iafrica.com!pipex-sa.net!plug.news.pipex.net!pipex!tank.news.pipex.net!pipex!news.be.innet.net!INbe.net!news.nl.innet.net!INnl.net!hunter.premier.net!news-res.gsl.net!news.gsl.net!news.mathworks.com!newsfeed.internetmci.com!in2.uu.net!usenet.cisco.com!lint.cisco.com!skrishna
From: Sridhar Krishnan <skrishna@cisco.com>
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: sh command shell script writing. i'm stuck
Date: Mon, 22 Jul 1996 17:24:40 -0700
Organization: cisco Systems, Incorporated
Lines: 35
Message-ID: <Pine.HPP.3.91.960722171415.29481F-100000@lint.cisco.com>
References: <4t02d1$nec@cliff.island.net>
NNTP-Posting-Host: lint.cisco.com
Mime-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
In-Reply-To: <4t02d1$nec@cliff.island.net> 

If you have (n)awk, try something like:

awk -v x=8 '(NR==x){ print $0; exit }'  file

x = line number you wish to print.


Sridhar Krishnan

On Mon, 22 Jul 1996, Victor Aker wrote:

> I am trying to import text one line at a time into a shell script that I am 
> writing, and having a real bugger of a time. I need to grab these lines one by 
> one, and explicitly state each time which line number it is (Only grabbing, as 
> an example, line 3 and line 3 only). So far, I have gotten this far:
> 
> tempuser=$(ls /home | cat -n | grep -G "$counter"
> 
> where counter is the number of the line. One problem, this output is giving me 
> the following:
> 
>         3       ets
> 
> where I only need
> 
> ets
> 
> 
> 
> Any script gurus out there?
> 
> Victor.
>  
> 
>