The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Printing value with no obvious field seperator Donkey25 Shell Programming and Scripting 4 03-14-2008 02:57 AM
sort columns by field kamel.seg Shell Programming and Scripting 4 02-20-2008 02:50 AM
How to change field seperator onthetopo Shell Programming and Scripting 2 05-11-2007 09:11 AM
regexp to print after a field seperator ramky79 Shell Programming and Scripting 7 05-09-2007 03:31 PM
Awk Field Seperator Help insania Shell Programming and Scripting 3 11-11-2005 12:29 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-13-2007
Registered User
 

Join Date: Jan 2007
Posts: 41
Stumble this Post!
find columns with whitespace as field seperator?

Hai

I am using

bash-2.03$ bash --version
GNU bash, version 2.03.0(1)-release (sparc-sun-solaris)

I am not able to use gawk command its showing command not found , why ?

Eg:
awk 'NR==1' fix.txt | gawk 'BEGIN { FIELDWIDTHS = "3 2" } { printf($1"|"$2); }'
---------------------------------------
bash: gawk: command not found
Broken Pipe

I want to find num of columns with whitespace as field seperator, is it possible with awk

Thank u
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 03-13-2007
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,572
Stumble this Post!
Code:
awk -F" " ' { print NF  }' filename
Not sure whether gawk is available in Solaris!
Reply With Quote
  #3 (permalink)  
Old 03-13-2007
Registered User
 

Join Date: Jan 2007
Posts: 41
Stumble this Post!
this will not work...as one column may also contain null(space) value..
the null value will be considered as seperator.

Eg:Inputfile
3445 56 67
23 2 45
07 06


output of 3rd line 2nd column must be null(empty)
Reply With Quote
  #4 (permalink)  
Old 03-13-2007
Technorati Master
 

Join Date: Mar 2005
Location: Large scale systems...
Posts: 2,572
Stumble this Post!
Quote:
Originally Posted by tkbharani
this will not work...as one column may also contain null(space) value..
the null value will be considered as seperator.

Eg:Inputfile
3445 56 67
23 2 45
07 06


output of 3rd line 2nd column must be null(empty)
Yes of course, it would be considered as a seperator!

So, may I know what is your expected output from the input file considering the null space also as a separator ?
Reply With Quote
  #5 (permalink)  
Old 03-13-2007
Registered User
 

Join Date: Jan 2007
Posts: 41
Stumble this Post!
3445 56 67
23 2 45
07 space 06


My out put for 3rd line 2nd column must be null(space) and should not be 06.
While counting number of column it should show as 3 column
Reply With Quote
  #6 (permalink)  
Old 03-13-2007
blowtorch's Avatar
Supporter
 
Join Date: Dec 2004
Location: Singapore
Posts: 2,325
Stumble this Post!
Sorry, but I think that your logic is wrong. How would you split this up:

3445space56space67
23space2space45
07spacespacespacespace

Does this mean that the columns for the last row should be 3? And if you are talking about NULL value - that would mean that the value simply does not exist and (in this case) the third row will have be:
07space06

Then how do you decide whether 06 is the second column or the third?
Reply With Quote
  #7 (permalink)  
Old 03-13-2007
Registered User
 

Join Date: Jan 2007
Posts: 41
Stumble this Post!
Because my data is Fixed width column...with that i can get 1st column and 2nd ..and so on
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:09 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0