Sponsored Content
Top Forums Shell Programming and Scripting Combine splitted low & high byte files into one file Post 302869973 by Chubler_XL on Thursday 31st of October 2013 04:26:06 PM
Old 10-31-2013
How about using perl:

Code:
#!/usr/bin/perl -w

open HI, $ARGV[0] || die $!;
binmode HI;
open LO, $ARGV[1] || die $!;
binmode LO;

my $hidata;
my $lowdata;

while (read(HI, $hidata, 1)) {

   read(LO, $lowdata, 1) || last;

   printf "%c%c", ord($hidata),ord($lowdata);
}
close HI;
close LO;

Eg:

Code:
$ printf "\x0\x2\x4\x6\x8\xA" > Hi
$ printf "\x1\x3\x5\x7\x9\xB" > Lo
$ ./ans.pl Hi Lo > result
$ od -t d1 result
0000000    0    1    2    3    4    5    6    7    8    9   10   11
0000014

This User Gave Thanks to Chubler_XL For This Post:
 

10 More Discussions You Might Find Interesting

1. Solaris

malloc returning NULL if freemem high & swapmem low

Hi All, In my application malloc is returning NULL even though there is sufficient amount of free memory is available but swap memory is low. Is this possible that, if free memory is high & swap memory is low, malloc will not be able to allocate memory & return NULL ?:) Kindly look into... (5 Replies)
Discussion started by: Ritesh Kumar
5 Replies

2. UNIX for Dummies Questions & Answers

malloc returning NULL if freemem high & swapmem low (MPRAS version 3.03 )

Hi All,:) In my application malloc is returning NULL even though there is sufficient amount of free memory available but the swap memory is low. Is this possible that, if free memory is high & swap memory is low, malloc will not be able to allocate memory & return NULL ? Few details: ... (4 Replies)
Discussion started by: Ritesh Kumar
4 Replies

3. Shell Programming and Scripting

low & high values

on the file Ftp'd from the mainframe ,do we have any UNIX command to replace mainframe low and values to space or null. i tried using tr and it doesn't work ... Thanks (1 Reply)
Discussion started by: rlmadhav
1 Replies

4. Shell Programming and Scripting

Picking high and low variables in a bash script - possible?

Is it possible to have a bash script pick the highest and lowest values of four variables? I've been googling for this but haven't come up with anything. I have a script that assigns variables ($c0, $c1, $c2, and $c3) based on the coretemps from grep/sed statements of sensors. I'd like to also... (5 Replies)
Discussion started by: graysky
5 Replies

5. Shell Programming and Scripting

Split file into chunks of low & high byte

Hi guys, i have a question about spliting a binary file into 2 chunks. First chunk with all high bytes and the second one with all low bytes. What unix tools can i use? And how can this be performed? I looked in manpages of split and dd but this does not help. Thanks (2 Replies)
Discussion started by: basta
2 Replies

6. UNIX for Dummies Questions & Answers

Kernel/ user space and high/ low mem

Need some clarification on this.... 1. how are kernel/ user spaces and high/low memory related? 2. What do they all mean when i have the kernel command line as: "console=ttyS0,115200 root=/dev/sda2 rw mem=exactmap memmap=1M@0 memmap=96M@1M irqpoll" or 2. what do mem and memmap mean in... (3 Replies)
Discussion started by: dragonpoint
3 Replies

7. Shell Programming and Scripting

How to combine 2 files and output the unique & difference?

Hi Guys, I have two input files and I want to combine them and get the unique values and differences and put them into one file. See below desired output file. Inputfile1: 1111111 2222222 3333333 7860068 7860069 7860071 7860072 Inputfile2: 4444444 (4 Replies)
Discussion started by: pinpe
4 Replies

8. AIX

High Runqueue (R) LOW CPU LOW I/O Low Network Low memory usage

Hello All I have a system running AIX 61 shared uncapped partition (with 11 physical processors, 24 Virtual 72GB of Memory) . The output from NMON, vmstat show a high run queue (60+) for continous periods of time intervals, but NO paging, relatively low I/o (6000) , CPU % is 40, Low network.... (9 Replies)
Discussion started by: IL-Malti
9 Replies

9. Shell Programming and Scripting

splitting newfile.txt file and executing each splitted files

split -l $split_count newfile.txt for i in $split_files* do if test -s $workingdir/$split_files* then ./<$i.out> fi done ... (4 Replies)
Discussion started by: sanjay mn
4 Replies

10. Red Hat

High RAM usage, extremely low swapping

Hi team I have three physical servers running on Red Hat Enterprise Linux Server release 6.2 with the following memory conditions: # cat /proc/meminfo | grep -i mem MemTotal: 8062888 kB MemFree: 184540 kB Shmem: 516 kB and the following swap conditions: ... (6 Replies)
Discussion started by: hedkandi
6 Replies
Net::netent(3pm)					 Perl Programmers Reference Guide					  Net::netent(3pm)

NAME
Net::netent - by-name interface to Perl's built-in getnet*() functions SYNOPSIS
use Net::netent qw(:FIELDS); getnetbyname("loopback") or die "bad net"; printf "%s is %08X ", $n_name, $n_net; use Net::netent; $n = getnetbyname("loopback") or die "bad net"; { # there's gotta be a better way, eh? @bytes = unpack("C4", pack("N", $n->net)); shift @bytes while @bytes && $bytes[0] == 0; } printf "%s is %08X [%d.%d.%d.%d] ", $n->name, $n->net, @bytes; DESCRIPTION
This module's default exports override the core getnetbyname() and getnetbyaddr() functions, replacing them with versions that return "Net::netent" objects. This object has methods that return the similarly named structure field name from the C's netent structure from netdb.h; namely name, aliases, addrtype, and net. The aliases method returns an array reference, the rest scalars. You may also import all the structure fields directly into your namespace as regular variables using the :FIELDS import tag. (Note that this still overrides your core functions.) Access these fields as variables named with a preceding "n_". Thus, "$net_obj->name()" corresponds to $n_name if you import the fields. Array references are available as regular array variables, so for example "@{ $net_obj->aliases() }" would be simply @n_aliases. The getnet() function is a simple front-end that forwards a numeric argument to getnetbyaddr(), and the rest to getnetbyname(). To access this functionality without the core overrides, pass the "use" an empty import list, and then access function functions with their full qualified names. On the other hand, the built-ins are still available via the "CORE::" pseudo-package. EXAMPLES
The getnet() functions do this in the Perl core: sv_setiv(sv, (I32)nent->n_net); The gethost() functions do this in the Perl core: sv_setpvn(sv, hent->h_addr, len); That means that the address comes back in binary for the host functions, and as a regular perl integer for the net ones. This seems a bug, but here's how to deal with it: use strict; use Socket; use Net::netent; @ARGV = ('loopback') unless @ARGV; my($n, $net); for $net ( @ARGV ) { unless ($n = getnetbyname($net)) { warn "$0: no such net: $net "; next; } printf " %s is %s%s ", $net, lc($n->name) eq lc($net) ? "" : "*really* ", $n->name; print " aliases are ", join(", ", @{$n->aliases}), " " if @{$n->aliases}; # this is stupid; first, why is this not in binary? # second, why am i going through these convolutions # to make it looks right { my @a = unpack("C4", pack("N", $n->net)); shift @a while @a && $a[0] == 0; printf " addr is %s [%d.%d.%d.%d] ", $n->net, @a; } if ($n = getnetbyaddr($n->net)) { if (lc($n->name) ne lc($net)) { printf " That addr reverses to net %s! ", $n->name; $net = $n->name; redo; } } } NOTE
While this class is currently implemented using the Class::Struct module to build a struct-like class, you shouldn't rely upon this. AUTHOR
Tom Christiansen perl v5.16.2 2012-08-26 Net::netent(3pm)
All times are GMT -4. The time now is 11:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy