Re: get the first word of a file




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

#to obtain all the dates
cat data | sed s/\|.*//

# to remove all the dates
cat data | sed s/[0-9]*\|// > $$ ; mv $$ data

Hope this helps,
William

.



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)