Display loop
I have a series of directories, with one file in each. The directories are numbered from 1-9. Each file has text which I wish to read and echo on to the display, however I want each of the files to be displayed in a particular pattern (as shown below):
111111111111111122222222222222223333333333333333 111111111111111122222222222222223333333333333333 111111111111111122222222222222223333333333333333 111111111111111122222222222222223333333333333333 111111111111111122222222222222223333333333333333 444444444444444455555555555555556666666666666666 444444444444444455555555555555556666666666666666 444444444444444455555555555555556666666666666666 444444444444444455555555555555556666666666666666 444444444444444455555555555555556666666666666666 777777777777777788888888888888889999999999999999 777777777777777788888888888888889999999999999999 777777777777777788888888888888889999999999999999 777777777777777788888888888888889999999999999999 777777777777777788888888888888889999999999999999 unfortunatley, in my script, i am getting no output at all, or an unexpected characters error. I am pretty sure that the error is in my syntax somewhere when using the sed command. Here is the display loop I am using: Code:
I=1 Thanks a bunch Craig J. Ward |
Code:
~/1/1 1111111111111111 There is little point in me setting out to catch a haggis if I'm unsure quite what it looks like! Oh and must you use SED for this homework(?) assignment? I'm looking forward to your confirmation of the general geography. |
OK, I was seeing that as each file is just text, and he wants a certain amount of the text printed in 9 sections around the screen as laid out in the grid. The contents of the files and their names (in fact I would guess each directory could hold more than one file) shouldn't be important (if my assumption is correct).
If I'm wrong, let me know. Forrest |
Yes, that is the directory structure which I am working with. No, I am not required to use sed. The content of the files and their names is not important, however, there will be only one file per directory. And the order in which I display the directories IS important
Thanks for your help |
other than sed, what command do you suggest I use?
|
Quote:
Code:
# assuming file contents only 1 line. eg file 1 has 1111111111111111 and Code:
# ../test.sh |
unfortunately the file's contents are more than one line (13 lines). And as much as I would like to use c++, I must use shell commands. Will this solution still work for me?
|
Quote:
|
I was just giving an example of how I wanted the output to be laid out. I am making a sliding puzzle game with an ascii art text file(s)
the actual output is: Code:
...I$: |
I'm new to scripting, is it possible to use the awk command to output text from a file line by line without using c++.
I'm sorry for being so frustrating. To clarify, here is the contents of file 1: Code:
Code:
.I$: Code:
|
If I have focused the problem, you have 9 tiles of a puzzle placed in 9 different directories, right? The problem is reduced to read the first 3 files simultaneously and print them line-by-line, then read the second 3 files and print them line-by-line, and so on.
To do this in shell scripting, you have to link three file descriptors with three input files and loop the process three times. An example can be Code:
#!/bin/bash Code:
1/ 2/ 3/ 4/ 5/ 6/ 7/ 8/ 9/ |
Thanks!
What exactly does the exec command do? I couldn't find a man page for it... How do I customize the redirect to my needs? I tried running the code given, and am getting ambiguous redirect errors. Thanks again |
|
Thanks, but I still don't understand why I am getting these ambiguous redirect errors... Is it because of the wildcard at the end of the path?
|
Quote:
Code:
exec 3< my_file To customize the redirect to your needs you have to simply build the path of each file. As I told you, I assumed the 9 directories were simply 1, 2, 3, and so on... and accordingly Code:
when row = 1 --> $((row * 3 - 2)) is 1 Code:
exec 3< $((row * 3 - 2))/* |
All times are GMT -5. The time now is 05:25 PM. |