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 Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

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 06:57 AM
sort columns by field kamel.seg Shell Programming and Scripting 4 02-20-2008 06:50 AM
How to change field seperator onthetopo Shell Programming and Scripting 2 05-11-2007 01:11 PM
regexp to print after a field seperator ramky79 Shell Programming and Scripting 7 05-09-2007 07:31 PM
Awk Field Seperator Help insania Shell Programming and Scripting 3 11-11-2005 04:29 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-13-2007
tkbharani tkbharani is offline
Registered User
  
 

Join Date: Jan 2007
Posts: 42
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
  #2 (permalink)  
Old 03-13-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,958

Code:
awk -F" " ' { print NF  }' filename

Not sure whether gawk is available in Solaris!
  #3 (permalink)  
Old 03-13-2007
tkbharani tkbharani is offline
Registered User
  
 

Join Date: Jan 2007
Posts: 42
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)
  #4 (permalink)  
Old 03-13-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,958
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 ?
  #5 (permalink)  
Old 03-13-2007
tkbharani tkbharani is offline
Registered User
  
 

Join Date: Jan 2007
Posts: 42
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
  #6 (permalink)  
Old 03-13-2007
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
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?
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:35 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0