Problem in making a list with awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Problem in making a list with awk
# 1  
Old 11-09-2012
Problem in making a list with awk

Hi bodies,I am doing a list from a .txt file with awk commands but something is wrong.
The .txt file looks like:
Code:
32782   28   18
 32783   02   18
 32784   01   18
 32785   29   18
 32786   25   23
 32787   25   18
 32788   00   18
 32789   25   26
 32790   02   23
 32791   29   26
 32792   23   26
 32793   01   23
 32794   28   23
 32795   00   23
 32796   00   26
 32797   28   26
 32798   02   26
 32799   01   26
 32800   21   27
 32801   23   27
 32802   02   27
 32803   00   27
 32804   28   27
 32805   25   27
 32806   29   27
 32809   28   30
 32810   00   30

and the code that I wrote is:
Code:
BEGIN{print"//start";}

{X[NR]=$1;Y[NR]=$2;Z[NR]=$3;
for (j=0; j<=31 ; j++)
{   for(i=1; i<=NR ; i++)
	{
	if (X[i]+1==X[i+1])
	{
	if (j==Y[i])
	{P=Y[i+1];
	stack[j,P]=1
	}
}
}
}

}
END{
for(j=0; j<=31; j++)
	{for (k=0; k<=31; k++)
		{print(j ,"  " k ,"  " stack[j,k])

}
}
}

It should list all the successive numbers (if the X[i]+1==X[i+1] is met), but it does not work for number less than 10
Code:
0   0   
0   1   
0   2   
0   3   
0   4   
0   5   
0   6   
0   7   
0   8   
0   9   
0   10   
0   11   
0   12   
0   13   1
0   14   1
0   15   
0   16   
0   17   
0   18   
0   19   1
0   20   
0   21   1
0   22   
0   23   1
0   24   1
0   25   1
0   26   1
0   27   1
0   28   1

Thanks for your help
Smilie
# 2  
Old 11-09-2012
I don't understand what you are trying to accomplish here. I think it needs a bit more prose. Also, what is the desired output?
# 3  
Old 11-09-2012
sorry for bad explanation , for example the desire output for example can be:
Code:
0   0   1
0   1   
0   2   1
0   3   
0   4   
0   5   1
0   6   
0   7   
0   8   
0   9   1
0   10   
0   11   
0   12   
0   13   1
0   14   1
0   15   
0   16   
0   17   
0   18   
0   19   1
0   20   
0   21   1
0   22   
0   23   1
0   24   1
0   25   1
0   26   1
0   27   1
0   28   1

but in the output that I obtained as you can see here
Code:
28   26   
28   27   1
28   28   
28   29   1
28   30   1
28   31   
29   0   
29   1   
29   2   
29   3   
29   4   
29   5   
29   6   
29   7   
29   8   
29   9   
29   10   1
29   11   1
29   12   
29   13   
29   14   
29   15   
29   16   1
29   17

whenever there is a number less than 10 in 2nd column I can't obtain a 1 in 3rd column
hope it make it more clear Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Making a play-list

approximately the same question as the last time, but unfortunately I didn't get a working answer. I made a script with bash and gtkdialog that create a play-list. The output is for example : gtk-media-pause | CB60471-05 - Gilbert, Brantley - Country Must Be Country Wide.zip | 28897 |... (3 Replies)
Discussion started by: jkfloris
3 Replies

2. Shell Programming and Scripting

problem in making Awk executable script

Guys I placed #!path/awk -f placed awk script and used $1 to call 1st inputfile inside the script. But some where I did mistake. Could you please help me run this script as executable I forgot to mention I also used BEGIN before placing awk script. But nothing worked out. Script ... (2 Replies)
Discussion started by: repinementer
2 Replies

3. Shell Programming and Scripting

Problem in making itration

Hi, I have a file which keeps on appending the data continuously, i that i am looking for a particular pattern, if i dont find that pattern i want to wait for 30 seconds to check it again. can we use it like this ----------------------------- until do cat $line |... (1 Reply)
Discussion started by: Prateek007
1 Replies

4. Shell Programming and Scripting

making a list matching certain criteria in bash...

Hello everyone!I am trying to make a mail list(a simple .txt file)in which i put certain records that match specific criteria. Let's say that i have a(sorted by last column file)like this one: 0100567 Bla1 Lala1 100 1234567 Bla2 Lala2 80 8769029 Bla3 Lala3 70 1001007 ... (0 Replies)
Discussion started by: bashuser2
0 Replies

5. Shell Programming and Scripting

[problem] making a backup files

Hi guys, I'm a little stuck on this problem, I've tried googling it and some trial and error but can't seem to get it working. Basically I need the script to: 1) create a directory called "mybackups", if it doesn't exist 2) go through all the .sh files in the current directory, and copy... (4 Replies)
Discussion started by: chazij
4 Replies

6. Shell Programming and Scripting

problem in making sftp script

Dear all I am bit new to shell scripting . I am implemented autossh between two sun solaris machines , so that when I use sftp it will not ask for the password. Now I need to make shell script in which I have to transfer files from one server to another server automatically through root... (8 Replies)
Discussion started by: girish.batra
8 Replies

7. UNIX for Advanced & Expert Users

problem in making autossh between windows and solaris

Dear all I am facing one problem which is related to enabling Autossh between windows and solaris machine. If suppose their are two servers, server A is having windows and server B is having Solaris.I install openssh server software for windows through sourceforge.net site. What my requirement... (7 Replies)
Discussion started by: girish.batra
7 Replies

8. Shell Programming and Scripting

Problem in making shell script

Dear all Dear Brother I am bit new to programming or shell scripting. I have given one shell script which is regarding combining all the 240 or less files in a particular folderwhich is related to one hour of the day. There will be 24 these kind of folders related to a day . It means there... (4 Replies)
Discussion started by: girish.batra
4 Replies

9. Programming

DDD making problem

Hi Everybody, I am trying to make the ddd-3.3.9 debugger. I installed all dependencies. this is what i get: # make Making all in themes make: Entering directory `/space/atoulan/ddd-3.3.9/themes' make: Nothing to be done for `all'. make: Leaving directory... (0 Replies)
Discussion started by: azazel11998
0 Replies
Login or Register to Ask a Question