Monday, 15 March 2010

linux - Is there a way to find how many spaces before the first item in awk? -


Here is the input_file:

  DEFHIZ  

What do I need to know is that the number of white space before the first item such as a (hypothetical) variable WHITE_SPACES

  awk '{print WHITE_SPACES $ 1}' input_file < / Code> 

will come back

  4D 8H  

Any good moves?

Try:

  awk '{print index ($ 0) , $ 1) - 1 $ 1} 'input_file'  

No comments:

Post a Comment