I've never been a fan of echo | some-command when it's not needed as it is very inefficient. This is a simple, yet hard coded approach that generates output exactly as you indicated:
EDIT: The first loop could be omitted and a single printf used. Initially I embedded the loop inside of the row loop, but realised that the output you wanted didn't show the 'seats' on any row but the header, and I just moved the code up without thinking about the fact that the loop was then not needed.
The code below is a bit more complex, but much more flexible assuming that the different aircraft configurations might need to be supported. The looping is also different to illustrate how you might fill in any kind of status for each seat (assigned, open, frequent-flier only, ,etc):
The number of rows and number of seats/row are entered on the command line; output from this script is like this:
Last edited by agama; 11-06-2011 at 01:40 PM..
Reason: clarification
For this code,
Is {1:-7} the syntax for declaring values like "1-7"?
I've done some research on the codes your provided.
For the first line it actually creates a variable "layout" indicating that "each name is an array variable" by using "-a".
Thus I assume in your "case" you were creating the array for the "seats" display.
But why is there a need for "case 8)" since I only need to display "AB CDE FG"?
I'm trying to retrieve the "seats" display from another flat file with a delimiter of "," to determine which seat is available.
The flat file data looks like this:
A1,A2,B3,B4,E4 etc.
I've tried using "grep" to retrieve the whole line and using "sed" to translate each value to "X" as an indication. However I'm stuck at how do I store the index for each value in my flat file so that it will be able to display correctly in my matrix.
Last edited by vinzping; 11-06-2011 at 09:07 PM..
Reason: For a better display on the codings
Hi
I do have a tab delimited file with 2 columns, which is stratified based on the first column. There are 1000's of values in the file.
Below is an example of the input file
1 AB
1 AC
1 CC
1 DD
2 AB
2 CC
2 AC
2 AB
3 CF
3 CC
3 DD
4 AC
4 CC
4 AD (5 Replies)
I want to create a Matrix template that uses vector. For the time being I want to create the following operations. I need setting the implementation for the operations.
Maybe I do not have to use a pointer either.
template <class T>
class Matrix {
protected:
typedef vector<T>* ... (2 Replies)
Hello,
Greetings!
please help me produce the following solution. I need
to produce one big matrix file from several files in different levels.
If it helps, the index folder provides information on chromosome index and
the data folder provides information on values for chromosomes.
there... (8 Replies)
Dear all,
I'm new in perl scripting and I'm trying to creating a matrix from a 3 column file sorting data in a particular manner. In the final matrix I need to have the first column "IDs" on the header of the columns and the second column values on the header of each row. And the value fo the... (2 Replies)
I'm trying to create a Matrix using bash. The expected output is
.AB CDE FG
1
2
3
4
5
6
7
I'm a newbie in shell language, really appreciate if there is anyone who can guide me with this.
Double post again, continued here (0 Replies)
Hi all, I'm a newbie in shell scripting and currently I'm trying to create a matrix using bash. The Output will look like this
AB CDE FG
1
2
3
4
5
6
7
I'm stuck on the ABCDEFG display.
printFlightSeats()
{
rows=7
columns=7
for ((i=0;i<=$rows;i++))
do (0 Replies)
Hi all,
Is there a way to convert full data matrix to linearised left data matrix?
e.g full data matrix
Bh1 Bh2 Bh3 Bh4 Bh5 Bh6 Bh7
Bh1 0 0.241058 0.236129 0.244397 0.237479 0.240767 0.245245
Bh2 0.241058 0 0.240594 0.241931 0.241975 ... (8 Replies)
I need to create a large matrix so that I can feed that matrix to MATLAB for processing. The problem is creating that matrix because my data is completely scattered around files.
1. I have one big dictionary file which has words in newlines, like
apple
orange
pineapple
2. I have some... (3 Replies)