PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > Discrepancy while reading and comparing binary files
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

Discrepancy while reading and comparing binary files

Réponse
 
LinkBack Outils de la discussion
Vieux 28/05/2007, 23h59   #1
Madhusudhanan Chandrasekaran
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Discrepancy while reading and comparing binary files

Hi,

I have a script readbinary.sh with the following three lines

#!/bin/bash
var=`cat binaryfile`
echo $var

but if I run the file readbinary.sh > trial and do a diff

vimdiff trial binaryfile they are not the same. Moreover the
size of the two files are not the same.This is the case even
if I modify the script to read line by line. This prompts me
to think that shell variables have some pre-specified size.

Also, the discrepancy in the start of the two files binaryfile
and trial is even more baffling.

Please advise where I might be going wrong.

Thanks in advance
_Madhu
  Réponse avec citation
Vieux 29/05/2007, 00h17   #2
Barry Margolin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Discrepancy while reading and comparing binary files

In article <f3fmt1$jrd$1@prometheus.acsu.buffalo.edu>,
Madhusudhanan Chandrasekaran <mc79@cse.buffalo.edu> wrote:

> Hi,
>
> I have a script readbinary.sh with the following three lines
>
> #!/bin/bash
> var=`cat binaryfile`
> echo $var
>
> but if I run the file readbinary.sh > trial and do a diff
>
> vimdiff trial binaryfile they are not the same. Moreover the
> size of the two files are not the same.This is the case even
> if I modify the script to read line by line. This prompts me
> to think that shell variables have some pre-specified size.
>
> Also, the discrepancy in the start of the two files binaryfile
> and trial is even more baffling.
>
> Please advise where I might be going wrong.
>
> Thanks in advance
> _Madhu


Since you didn't quote "$var", the shell will perform word splitting
(essentially replacing all runs of whitespace with a single space) and
wildcard processing.

Also, if there are any NUL characters in the file, they'll be discarded
by the shell.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 07h46.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,07779 seconds with 10 queries