Re: get the first word of a file



William.Deans@xxxxxxxxx wrote:
> dufffman@xxxxxxxxx wrote:
> > Hi,
> >
> > I have a data file of the format
> >
> > 20051112|data|moreData|evenMoreData|..|
> > 20051112|data|moreData|evenMoreData|..|
> > 20051112|data|moreData|evenMoreData|..|
> > 20051112|data|moreData|evenMoreData|..|
> > 20051112|data|moreData|evenMoreData|..|
> > 20051112|data|moreData|evenMoreData|..|
> > 20051112|data|moreData|evenMoreData|..|
> >
> >
> > its going to be a pipe delimited file, w/the only the first date beng
> > the constant. in unix which command would i write to extract the first
> > '20051112' out of this file?
> >
> > Thanks,
>
> Greetings,
>
> I am not quite sure what you are asking.
>
> #to obtain the FIRST DATE ONLY
> cat data | sed s/\|.*// | head -1

sed can read a file. cat serves no purpose.

awk '{print $0 + 0 ; exit}' myfile

.



Relevant Pages

  • How to read a data file which the No. of Lines is unknown reviously?
    ... I need to input several data file generated by some experimental equipment. ... The files are in text format. ... Prev by Date: ...
    (comp.lang.fortran)
  • Using Excel as data source
    ... When I use an Excel file as my data file, is there any way that I can get ... format in Excel but when I mailmerger the data the format is lost. ... Prev by Date: ...
    (microsoft.public.word.mailmerge.fields)
  • about binaryreader
    ... but i have to use fixed length to read data in file(old format). ... Here fixed length means the count of bytes read not the count of chars read. ... because there are 2-byte chars in the data file. ... Prev by Date: ...
    (microsoft.public.dotnet.general)
  • Re: Dates - Have Cake, Eat too
    ... Vaya con Dios, ... > there is no way to format the entire column and acheive the stated goal. ... > the purpose. ... Prev by Date: ...
    (microsoft.public.excel.misc)
  • Dates - Have Cake, Eat too
    ... Because of multiple user input, I would like to make this ... there is no way to format the entire column and acheive the stated goal. ... the purpose. ... Prev by Date: ...
    (microsoft.public.excel.misc)