Re: awk quries




"NewBie" <leongyc@xxxxxxxxx> wrote in message news:42c238d8$1@xxxxxxx
> Example there is a file called data.txt consists of:
>
> /usr/local/record
> /usr/local/record
> /usr/local/record
> /usr/local/record
>
>
> Now I just want to have an output with only a single line of:
>
> /usr/local/record
>
> How to go about it with awk?
>
> If I will to print only 2nd line, is it possible also?
>

Please don't top-post. It makes it harder for people to help you.

To simulate the Unix tool, uniq, and print only the first of
successive duplicate lines:

$0 !~ lastline { print }
{ lastline = $0 }

To print only the second line (or record):

NR == 2 { print }

--
John.



.



Relevant Pages

  • Using single input to query multiple non joined tables
    ... Table 1 consists of the fields: Name (primary key), phone number, address ... I can easily run a parameter query on Table 2 which returns entries ... where John is entered will return the desired entries with number 151, 152, ...
    (microsoft.public.access.gettingstarted)
  • Transfer Project table into word table
    ... a number of selected tasks. ... Kamil ... Prev by Date: ...
    (microsoft.public.project)
  • Re: electrostatic confusion
    ... John O'Flaherty wrote: ... > A problem from my physics book: ... > The circuit in figure P26.25 consists of two identical parallel metallic ...
    (sci.physics)
  • Nested Datalists
    ... The application I'm creating consists of a DataGrid with 3 (at this ... This creates each a column that lists all Distinct Items: ... Prev by Date: ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: commutator subgroup...closed
    ... If G is a group and X is a nonempty subset of G, then the subgroup ... generated by X consists of all finite products ^n_1) ... ... Prev by Date: ...
    (sci.math)