Sponsored Content
Top Forums Shell Programming and Scripting Problem in making a list with awk Post 302729129 by Behrouzx77 on Friday 9th of November 2012 05:21:30 AM
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
 

9 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

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

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

7. 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

8. 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

9. 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
dos2unix(1)						      General Commands Manual						       dos2unix(1)

NAME
dos2unix - DOS/MAC to UNIX text file format converter SYNOPSYS
dos2unix [options] [-c convmode] [-o file ...] [-n infile outfile ...] Options: [-hkqV] [--help] [--keepdate] [--quiet] [--version] DESCRIPTION
This manual page documents dos2unix, the program that converts plain text files in DOS/MAC format to UNIX format. OPTIONS
The following options are available: -h --help Print online help. -k --keepdate Keep the date stamp of output file same as input file. -q --quiet Quiet mode. Suppress all warning and messages. -V --version Prints version information. -c --convmode convmode Sets conversion mode. Simulates dos2unix under SunOS. -o --oldfile file ... Old file mode. Convert the file and write output to it. The program default to run in this mode. Wildcard names may be used. -n --newfile infile outfile ... New file mode. Convert the infile and write output to outfile. File names must be given in pairs and wildcard names should NOT be used or you WILL lost your files. EXAMPLES
Get input from stdin and write output to stdout. dos2unix Convert and replace a.txt. Convert and replace b.txt. dos2unix a.txt b.txt dos2unix -o a.txt b.txt Convert and replace a.txt in ASCII conversion mode. Convert and replace b.txt in ISO conversion mode. Convert c.txt from Mac to Unix ascii format. dos2unix a.txt -c iso b.txt dos2unix -c ascii a.txt -c iso b.txt dos2unix -c mac a.txt b.txt Convert and replace a.txt while keeping original date stamp. dos2unix -k a.txt dos2unix -k -o a.txt Convert a.txt and write to e.txt. dos2unix -n a.txt e.txt Convert a.txt and write to e.txt, keep date stamp of e.txt same as a.txt. dos2unix -k -n a.txt e.txt Convert and replace a.txt. Convert b.txt and write to e.txt. dos2unix a.txt -n b.txt e.txt dos2unix -o a.txt -n b.txt e.txt Convert c.txt and write to e.txt. Convert and replace a.txt. Convert and replace b.txt. Convert d.txt and write to f.txt. dos2unix -n c.txt e.txt -o a.txt b.txt -n d.txt f.txt DIAGNOSTICS
BUGS
The program does not work properly under MSDOS in stdio processing mode. If you know why is that so, please tell me. AUTHORS
Benjamin Lin - <blin@socs.uts.edu.au> Bernd Johannes Wuebben (mac2unix mode) <wuebben@kde.org> MISCELLANY
Tested environment: Linux 1.2.0 with GNU C 2.5.8 SunOS 4.1.3 with GNU C 2.6.3 MS-DOS 6.20 with Borland C++ 4.02 Suggestions and bug reports are welcome. SEE ALSO
unix2dos(1) mac2unix(1) 1995.03.31 dos2unix v3.0 dos2unix(1)
All times are GMT -4. The time now is 02:27 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy