Unix Programming - Re: Way to get a set of string from the data already existing on

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > February 2006 > Re: Way to get a set of string from the data already existing on





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Re: Way to get a set of string from the data already existing on
Nils O. Selåsdal

2006-02-26, 10:16 am

Savte wrote:
> Hi everyone,
>
> Does there exist any way under shell programming to capture a line (say
> line 13 ) and save it
> to a string and manipulate? As an example of the functionality that i
> am looking for:
> Suppose you a terminal with display like this:
>
> Hello everyone
>
> Unix Shell Scripting
>
> When i run my script, i would like to get line 3(displayed ) and save
> it to string for further manipulation.


I'm not quite sure where the text you want to get is, if it's the
output of a command you could get it like e.g.
theprog | head -13 |tail -1
or to put it in a sh variable 'var'
var=$(yourprog | head -13 |tail -1)
echo $var

This won't be very effective if it's a large lineno, not
something small as line 13
There's probably more elegant solutions in awk/sed/perl/etc. for that.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com