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
awk -F" " ' { print NF }' filename
Not sure whether gawk is available in Solaris!
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)
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 ?
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
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?
Because my data is Fixed width column...with that i can get 1st column and 2nd ..and so on
By fixed column in a record
does that mean, c1 will have exactly 10 chars, c2 will have exactly 10 chars
or
c1 can have a maximum of 10 chars, c2 can have a maximum of 10 chars
Because, there is difference between exactly ' n ' chars and can have a maximum of ' n ' chars !
Then the example you've given us is not correct is it? Your first column is of different widths in the first row compared to the second and the third row.