[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[SLUG] Re: Script Help
On Sun, Jul 02, 2000 at 09:46:04AM +1000, pworboys@nospam.awa.com.au wrote:
> What command(s) can I use to return a specific line within a data file.
> i.e: I need to return Line 2 of a file to a shell variable for further
> processing.
depends how many other things you want to do at the same time ;)
var=`sed -n '2p; 2q' file`
(the "2q" makes sed exit on the second line too, otherwise it'll keep
going through the rest of the file)
or
var=`awk 'NR == 2 {print; exit}' file`
just for completeness:
var=`perl -ne 'if ($. == 2) { print; exit }'`
--
- Gus
--
SLUG - Sydney Linux Users Group Mailing List - http://www.slug.org.au
To unsubscribe send email to slug-request@nospam.slug.org.au with
unsubscribe in the text