Re: get the first word of a file
- From: "William.Deans@xxxxxxxxx" <William.Deans@xxxxxxxxx>
- Date: 21 Dec 2005 07:12:38 -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?
>
> 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
.
- Follow-Ups:
- Re: get the first word of a file
- From: William James
- Re: get the first word of a file
- From: Hubble
- Re: get the first word of a file
- From: dufffman
- Re: get the first word of a file
- References:
- get the first word of a file
- From: dufffman
- get the first word of a file
- Prev by Date: Re: Why can I see the exectuing script?
- Next by Date: Re: get the first word of a file
- Previous by thread: get the first word of a file
- Next by thread: Re: get the first word of a file
- Index(es):
Relevant Pages
|