Unix Programming - cut not counting whitespaces

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > October 2006 > cut not counting whitespaces





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author cut not counting whitespaces
Raghav

2006-10-13, 1:40 am

Hi,

I have this file wherein i am trying to cut based on characters.

Since the file is a fixed length one, there are spaces present to mark
field start-end. my cut instruction however, does not seem to count the
spaces as characters (i use -c). I also tried -b but to no avail.

I have not yet tried PERL or any other tool... just wondering on
behvior of cut.

Any ideas ?

cheers
raghav..

QQ

2006-10-13, 1:40 am

try awk, it got more built-in functions, wish it helps.
I am not quite good at it, but it will do what u want i reckon.

Steven

Raghav wrote:
> Hi,
>
> I have this file wherein i am trying to cut based on characters.
>
> Since the file is a fixed length one, there are spaces present to mark
> field start-end. my cut instruction however, does not seem to count the
> spaces as characters (i use -c). I also tried -b but to no avail.
>
> I have not yet tried PERL or any other tool... just wondering on
> behvior of cut.
>
> Any ideas ?
>
> cheers
> raghav..


Doug McIntyre

2006-10-13, 1:40 am

"Raghav" <sharma.raghvendra@gmail.com> writes:
>I have this file wherein i am trying to cut based on characters.


>Since the file is a fixed length one, there are spaces present to mark
>field start-end. my cut instruction however, does not seem to count the
>spaces as characters (i use -c). I also tried -b but to no avail.


>I have not yet tried PERL or any other tool... just wondering on
>behvior of cut.


>Any ideas ?


Are they spaces? or are they tabs expanding out to spaces?

When counting characters, one tab character can expand out to look
like several spaces.

If your file has mixed tabs and spaces, its probably better to define
the delimeter to be tab and go by fields instead of characters.

Or use awk/perl which would have better field seperation guessing than
cut does.

noogie.brown@gmail.com

2006-10-13, 7:33 am


Raghav wrote:
> Hi,
>
> I have this file wherein i am trying to cut based on characters.
>
> Since the file is a fixed length one, there are spaces present to mark
> field start-end. my cut instruction however, does not seem to count the
> spaces as characters (i use -c). I also tried -b but to no avail.
>
> I have not yet tried PERL or any other tool... just wondering on
> behvior of cut.
>
> Any ideas ?
>
> cheers
> raghav..


Have you tried cut with -f and -d' ' ?

Richard B. Gilbert

2006-10-13, 1:27 pm

Raghav wrote:

> Hi,
>
> I have this file wherein i am trying to cut based on characters.
>
> Since the file is a fixed length one, there are spaces present to mark
> field start-end. my cut instruction however, does not seem to count the
> spaces as characters (i use -c). I also tried -b but to no avail.
>
> I have not yet tried PERL or any other tool... just wondering on
> behvior of cut.
>
> Any ideas ?
>
> cheers
> raghav..
>


I don't use cut much but this sounds like a job for awk/nawk/gawk.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com