First of all, I am trying to duplicate the sum command using ksh/nawk
Lets assume the following algorithms work just fine and there is no calculation errors what so ever (which I doubt at this minute).
For now, I wanna make sure the script uses the BSD algorithim if -r is used and it uses the SysV algorthim if no option is used. Also, I have another problem is, how to get binary data in a form nawk can manipulate. I want to convert it to ASCII hex 1st using dhex -X . If you look at the script you will see I am using hex_to_dec nawk script later on.
I will post both the nawk/ksh and the original c file
Please bear with me, this is my 1st nawk/ksh script.
The Dhex mentioned above, here is its man page :
DHEX
DESCRIPTION
Dhex reads a file from the standard input, and dumps it on
the standard output. If no options are given, the ouput is in
hex and ascii format. If the -u option is specified, the
hex is output in upper case. If the -x option is specified, just
the hexadecimal portion is output. If the -X option is specified,
the hexadecimal portion is output in 160 column lines.
When used with chex and a text editor, dhex provides the ability
to patch any byte of any file. Simply convert the file to a hex
and ascii dump using dhex. Edit the bytes to be patched with
a text editor. Finally, create the patched file using chex.
OPTIONS
-a Format the output like the output of the disk array controller
debugger's dump command. Ignore the -u, -x, and -X options.
-h Print this manual page, and take no further action.
-l Print the specified number of bytes. The length can be specified
in decimal, or in hexadecimal with a 0x prefix. If the -l option
is not specified, the default is to dump until the end of file is
reached.
-s Seek offset bytes into the standard input before dumping.
Offset can be specified in decimal, or in hexadecimal with
a 0x prefix. The seek offset must be an even multiple of 16.
If it is not, it is rounded down to the nearest multiple.
-u Output the hexadecimal digits in upper case.
-x Output just the hexadecimal digits. This can be used to
prepare a file for an ASCII file transfer. When combined with
a sumcheck program such as crc or fletcher, a reliable file
transfer can be achieved.
-X Similar to -x, except it prints 160 hexadecimal digits per line.
This is often more convenient if the ASCII file transfer is to
be done using a mouse.
Hi.. i am running nawk scripts on solaris system to get records of file1 not in file2 and find duplicate records in a while with the following scripts -compare
nawk 'NR==FNR{a++;next;} !a {print"line"FNR $0}' file1 file2duplicate - nawk '{a++}END{for(i in a){if(a-1)print i,a}}' file1in the middle... (12 Replies)
hi guys,
I am writing a code and have stuck at one point. Inside nawk I am storing my desired variable a, I just need to find if a is present in an external file error.log or not. If yes, print something. grep or for loop not working properly inside nawk. Sample code provided.
nawk '
BEGIN... (5 Replies)
Hi! I am having a bit of a problem with my script. There are two different date formats that may appear in a file, either Jul-12 or Jul--6. I tried to create an if statement that searches for one of the formats and if that doesn't exist searches for the other, however it doesn't seem to be... (3 Replies)
I am trying to use either awk or nawk in ksh88 to grep the word "Reason" in multiple files and than print the lines that say "Reason" in a particular format that is different from how they would normally print. The original input is as follows:
... (10 Replies)
help out with code. two files aaa bbb contains some records..output file xyz should be like this..see below
i/p file:aaa
08350|60521|0000|505|0000|1555|000|NYCMT|Pd_1 |-11878
i/p file: bbb
60521|60510
o/p file :xyz
60510|08350|60521|0000|505|0000|1555|000|NYCMT|Pd_1 |-11878 (5 Replies)
Hi
I am new to this Scripting process and would like to know How can i write a ksh script that will call other ksh scripts and write the output to a file and/or email.
For example
-------
Script ABC
-------
a.ksh
b.ksh
c.ksh
I need to call all three scripts execute them and... (2 Replies)
I'm not confident at all on how arrays work.
I want to know how to set arrays in ksh and in nawk (is there a difference??)
if someone can show me some examples of both that will be great. Tried to look up on the net but was confusing me more.
Any help would be appreciated. (2 Replies)
i'm new to shell scripting and have a problem please help me
in the script i have a nawk block which has a variable count
nawk{
.
.
.
count=count+1
print count
}
now i want to access the value of the count variable outside the awk block,like..
s=`expr count / m`
(m is... (5 Replies)
I found a command who prints x lines before and after a line who contain a searched string in a text file.
The command is :
-------------------
nawk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r;print;c=a}b{r=$0}' b=2 a=4 s="string" file1
...where "b" and "a" are the number of lines to print... (2 Replies)