Re: get the first word of a file



On 21 Dec 2005 07:02:16 -0800, 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?
[...]

< file cut -d\| -f1 | head -n1

or

sed 's/|.*//;q' < file

--
Stephane
.



Relevant Pages

  • Re: get the first word of a file
    ... > I have a data file of the format ... > its going to be a pipe delimited file, w/the only the first date beng ...
    (comp.unix.shell)
  • Re: get the first word of a file
    ... > I have a data file of the format ... > its going to be a pipe delimited file, w/the only the first date beng ...
    (comp.unix.shell)
  • Re: get the first word of a file
    ... > I have a data file of the format ... > its going to be a pipe delimited file, w/the only the first date beng ...
    (comp.unix.shell)
  • get the first word of a file
    ... I have a data file of the format ... its going to be a pipe delimited file, w/the only the first date beng ...
    (comp.unix.shell)
  • Re: Using dates during mail merge
    ... The other thing that might be causing problems here is that, regardless of how the DATE field nested in the ASK field is formatted, the user will need to enter the date in the format set up in their regional options (or any other format where the month and day are not ambiguous. ... I was however remiss in not changing the field name from that in my data file as this added some unwelcome confusion:( ... You included 'MyDate' and 'Date2' in your ...
    (microsoft.public.word.mailmerge.fields)