Re: get the first word of a file
- From: Stephane Chazelas <stephane_chazelas@xxxxxxxx>
- Date: 21 Dec 2005 15:31:04 GMT
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
.
- References:
- get the first word of a file
- From: dufffman
- get the first word of a file
- Prev by Date: Re: get the first word of a file
- Next by Date: Re: bash + arrays + combinations
- Previous by thread: Re: get the first word of a file
- Next by thread: Re: get the first word of a file
- Index(es):
Relevant Pages
|