line beginning with a blank 
Author Message
 line beginning with a blank

Hello,

sorry, but I can't reach my detecting
Lines that begin with a blank

neither with:
    while ($0 ~ /^ /)
nor with
    while ($0 ~ /^[:blank:]/)
nor with
    while (substr($0,1,1) == " ")

can somebody help me?

thx
Ekkard



Thu, 10 Jul 2003 01:44:29 GMT  
 line beginning with a blank
Ekkard Gerlach wrote on Sat, 20 Jan 2001 17:44:29 +0000:

Quote:
> Hello,

> sorry, but I can't reach my detecting
> Lines that begin with a blank

> neither with:
>     while ($0 ~ /^ /)
> nor with
>     while ($0 ~ /^[:blank:]/)
> nor with
>     while (substr($0,1,1) == " ")

> can somebody help me?

what happens when you run this 4-character program:

/^ /

it should print lines beginning with a blank
(if it works, perhaps your problem lies elsewhere?)
--
Peter



Thu, 10 Jul 2003 02:47:37 GMT  
 line beginning with a blank


Quote:
>Hello,

>sorry, but I can't reach my detecting
>Lines that begin with a blank

>neither with:
>    while ($0 ~ /^ /)
>nor with
>    while ($0 ~ /^[:blank:]/)
>nor with
>    while (substr($0,1,1) == " ")

>can somebody help me?

>thx
>Ekkard

awk '/^ / {next} {print}' infile

deletes those lines and prints the others.

Chuck Demas

--
  Eat Healthy    |   _ _   | Nothing would be done at all,

  Die Anyway     |    v    | That no one could find fault with it.



Thu, 10 Jul 2003 02:57:16 GMT  
 line beginning with a blank

Quote:

...

> >neither with:
> >    while ($0 ~ /^ /)
> >nor with
...

> awk '/^ / {next} {print}' infile

> deletes those lines and prints the others.

thanks, but
definitely not. I already tried it, see my postings
in my first mail. I tried your syntax, too.

Quote:

...
> what happens when you run this 4-character program:

> /^ /

nothing ...  :-)

Quote:

> it should print lines beginning with a blank

no, see above, but thanks, Peter.

Any other hints?  - I wonder if it's hard problem ...
Hmmmm ...

Ekkard
using 2.2.14, gawk-3.0.4-73



Thu, 10 Jul 2003 07:15:15 GMT  
 line beginning with a blank

Quote:

> Any other hints?  - I wonder if it's hard problem ...
> Hmmmm ...

It should be a very easy problem.  You are making it hard by not
showing some data and explaining what you want to do with it.

What are `detecting lines'?

Are you sure the spaces aren't really tabs?



Thu, 10 Jul 2003 08:52:42 GMT  
 line beginning with a blank

...

Quote:
>sorry, but I can't reach my detecting
>Lines that begin with a blank

>neither with:
>    while ($0 ~ /^ /)
>nor with
>    while ($0 ~ /^[:blank:]/)
>nor with
>    while (substr($0,1,1) == " ")

>can somebody help me?

The second should be

while ($0 ~ /^[[:blank:]]/)

If this doesn't work, you don't have whitespace at the beginning of the
line even if it's displayed as whitespace. You can confirm this with

od -t x1 inputfile |
awk '{ for (f = 2; f <= NF; ++f)
         if (n && $f ~ /09|20/) print $1; else n = ($f == "0a") }'

If this gives no output, you have no newlines followed by ASCII tabs
(0x09) or spaces (0x20).

Sent via Deja.com
http://www.deja.com/



Thu, 10 Jul 2003 10:06:30 GMT  
 line beginning with a blank
Ekkard Gerlach wrote on Sat, 20 Jan 2001 23:15:15 +0000:

"nothing"

I strongly suspect the problem lies not with awk :-)

Please feed this to your shell:

(echo "XX"; echo " Y"; echo "Z ")|awk '/^ /'

You should get " Y"

If you don't, I'll eat my words.

--
Peter



Thu, 10 Jul 2003 13:36:24 GMT  
 line beginning with a blank

Quote:


> > Any other hints?  - I wonder if it's hard problem ...
> > Hmmmm ...

> It should be a very easy problem.  You are making it hard by not
> showing some data and explaining what you want to do with it.

> What are `detecting lines'?

> Are you sure the spaces aren't really tabs?

Uhhrghh ! Your're right! My blanks are tabs.
All works like you all proposed.

Thank you all
Ekkard



Fri, 11 Jul 2003 00:54:15 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. remove blank lines before lines beginning with string

2. blank lines/lines with spaces (how to remove)

3. Inserting text at the beginning of a line

4. whitespace at beginning of second line

5. how to insert character at the beginning of each line in a file

6. how can i count line wich begins with NCOUNT word

7. appending to beginning of line

8. Beginning of lines in text widget

9. Remove lines beginning with # from file

10. inserting a blank line in a file

11. to insert a blank line

12. adding blank lines to text file

 

 
Powered by phpBB® Forum Software