No 1 answering my question... any reason ?

can some one please help me at my post ?

for hours yet being ignored

Need help on this:

  nonsense. can't even solve forum ask people redo whole code. LMAO - after asking 101 qns

the pre result should be like this:

A     A A A A
A A A A   A A
A   A   A A A
A A   A A A A
A     A A A A
A A A A   A A
A A A     A A

result

A B A A A A B
A A A A B A A
A B A B A A A
A A B A A A A
A B A B A A A
A A A A B A A
A A A B B A A

where B should be filled into those gaps.
can't seems to allocate any Bs if there are more than 10 gaps any reason where went wrong ?

thanks

---------- Post updated 10-30-11 at 12:20 AM ---------- Previous update was 10-29-11 at 02:44 PM ----------

assistance required, thanks

nanochan1,
these forums are not your paid-for support organization or 1-800-HELPME.
We do the best we can to providing assistance to the folks, but we're a bunch of volunteers with no contractual obligations.

Please be patient and someone will assist you.

To the point... rather than providing your code (which is good) I'd try verbalize what you're after and provide a more representative data samples: before and after. Looking at your samples I don't see the transformation logic.

how about this:

tr ' ' '#' < myFile  | sed 's/##/ B/g;s/#/ /g'

where myFile looks like this with 'gaps':

A     A A A A
A A A A   A A
A   A   A A A
A A   A A A A
A     A A A A
A A A A   A A
A A A     A A

Please provide the input and the expected output and some explanation.

We are all very happy to help everyone who comes here. But like the mod said, it is a voluntary service. And more over its a weekend! :wink:

--ahamed

sorry and thanks.

i don't quite understand the assistance vgersh99 provided me.

the code given what is it for ?

---------- Post updated at 08:01 PM ---------- Previous update was at 07:59 PM ----------

lets say i read in a file...

it shows the available spaces remaining from a file

eg.

if the remaining spaces are less or equal to 9 the compiler will run & allocate without any issues (as above), but if i set remaining spaces to be more than 10 spaces out of the 20 spaces

eg.

my compiler will simply hang and not do anything.

what i need to do is... eg i tell the compiler i need 4 spaces to be allocated to the remaining gaps - automatically.
the compliler will then start checking through and slot whichever gaps it could find with B and my result should return like this for instance:

and if i need 8 spaces to be filled it will be

and if 13 spaces needed to be filled

the codes which i tried to do as show on post #1 only could work for spaces not more than 9 remaining.

eg.

I am trying to figure out your logic... Meantime can you post your entire code, inputs to the script and the input file?...

--ahamed

PS: Thank you for using code tags!

awk 'NR==FNR{x=length($0)>x?length($0):x;next}{gsub(FS,OFS);while(length($0)<x)$0=$0OFS}1' OFS=B file file

what does this code do and where should i place it or replace it?

thanks.

If you look close enough both of the solutions take input a file named 'file' in case of danmero's hint or 'myFile' in my case.
Just run the solution(s) with whatever input file name you have.
Am I answer your question or misreading it?

Cant this:

awk 'NR==FNR{x=length($0)>x?length($0):x;next}{gsub(FS,OFS);while(length($0)<x)$0=$0OFS}1' OFS=B file file

and this

tr ' ' '#' < myFile  | sed 's/##/ B/g;s/#/ /g'

Be simplified to this:

sed 's/ /B/g' file

and this

sed 's/  / B/g' myFile

stop giving others false hope

The data you've shown below doesn't remotely resemble what you showed earlier. :confused:

What is the actual input you have and what is the actual output you want and what do they have to do with each other? And what shell are you using? :wall:

That's a dangerous use of backticks and useless use of cat.

This is faster and safer:

while IFS="" read LINE
do
        ...
done < filename.txt

This can be modified further, since read can do splitting by itself:

while IFS=":" read A B
do
        # $A iwill be "10", $B will be "A1 B1 D2 ..."
done < filename.txt

i thought what he meant is that my "this" part of the code is wrong ?

I can't see what you're even trying to do, so it's very difficult to offer suggestions.

If you answered any of the questions I asked at all, that would help a lot.

nvm... should have expected it

Thank you, now I understand. I didn't see how the 10:... line related to anything else until you explained it.

Most of this was not mentioned in your first post, by the way, or shown in a completely different format.

Working on something.

yeah right. if by reading i uds, i will not be here.

I don't think you're going to get what you want with sed. You need a language with proper arrays, like awk.

You never did answer my question about what shell you have. What system you have would be good, too. What you want may not be available in all systems.

erm... gedit from Ubuntu

gedit is an editor, not a shell.

But since you have ubuntu, you have BASH and gawk, which is useful to know.