Unix Programming - Expertise Required With dd command

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > November 2005 > Expertise Required With dd command





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Expertise Required With dd command
pankaj_wolfhunter@yahoo.co.in

2005-10-25, 5:53 pm

hi,
I want to extract some bytes of data from file1 to file2. I am
using dd command to specify the bytes and output file name. but it does
not perform as required. Here is my command:

dd count=1 bs=1046459 if=file1.txt of=file2.txt

I have specified the bytes required but the command takes some couple
of bytes extra.

I have tried everything but this behaviour repeats again & again. Can
anyone help me on this?

TIA

Jordon Hofer

2005-10-25, 5:53 pm

if you are pulling text from the beginning, maybe the head command would
work for you. maybe try something like

head -c 1046459 file1.txt > file2.txt

jorj

<pankaj_wolfhunter@yahoo.co.in> wrote in message
news:1130251250.836988.235430@g49g2000cwa.googlegroups.com...
> hi,
> I want to extract some bytes of data from file1 to file2. I am
> using dd command to specify the bytes and output file name. but it does
> not perform as required. Here is my command:
>
> dd count=1 bs=1046459 if=file1.txt of=file2.txt
>
> I have specified the bytes required but the command takes some couple
> of bytes extra.
>
> I have tried everything but this behaviour repeats again & again. Can
> anyone help me on this?
>
> TIA
>



pankaj_wolfhunter@yahoo.co.in

2005-10-26, 2:49 am

Jordon, thnx for the reply. Actually we want to extract data from that
file with different byte positions. This was just an example. So in
first case we may extract data from the start of the file and output
the result in one file and then in second case from the middle of the
file to some other output file and so on.
Is there any way the dd file can give us exact result? Is there any
other alternative to dd?

TIA

Luotao Fu

2005-10-26, 7:54 am

pankaj_wolfhunter@yahoo.co.in schrieb:
> hi,
> I want to extract some bytes of data from file1 to file2. I am
> using dd command to specify the bytes and output file name. but it does
> not perform as required. Here is my command:
>
> dd count=1 bs=1046459 if=file1.txt of=file2.txt
>
> I have specified the bytes required but the command takes some couple
> of bytes extra.
>
> I have tried everything but this behaviour repeats again & again. Can
> anyone help me on this?
>
> TIA
>


user@odysseus:~$ dd count=1 bs=1046459 if=/dev/zero of=test.out
1+0 Datensätze ein
1+0 Datensätze aus
1046459 bytes transferred in 0,011986 seconds (87306558 bytes/sec)
user@odysseus:~$ ls -al test.out
-rw-r--r-- 1 user user 1046459 2005-10-26 13:01 test.out


?????

works for me. You have to describe your problem more precisely.

Cheers
Luotao Fu
pankaj_wolfhunter@yahoo.co.in

2005-10-26, 7:54 am

thanx for the reply again.
here is what happening.

i have a file(clob.txt) of size 4992680. i use the following command

dd count=1 bs=1047142 if=clob.txt of=out.txt
1+0 records in
1+0 records out

now i do ls -al out.txt
-rw-r--r-- 1 miguser mig 1047142 Oct 26 16:43 out.txt

When i open this file using some editor like EditPlus, it and when i do
select all, the number of bytes shown are 1098101.

In unix command shell it shows the size as 1047142 and when i open and
check the file size its 1098101. Here i am getting some bytes extra.

I am unable to figure out whats the problem?

Thanx

moi

2005-10-26, 7:54 am

pankaj_wolfhunter@yahoo.co.in wrote:
> Jordon, thnx for the reply. Actually we want to extract data from that
> file with different byte positions. This was just an example. So in
> first case we may extract data from the start of the file and output
> the result in one file and then in second case from the middle of the
> file to some other output file and so on.
> Is there any way the dd file can give us exact result? Is there any
> other alternative to dd?
>
> TIA
>


You don't need the bs=xxx option.
Check count=xxx && skip=yyy

It's all in TFM ...

HTH,
AvK
Luotao Fu

2005-10-26, 7:54 am

pankaj_wolfhunter@yahoo.co.in schrieb:
> thanx for the reply again.
> here is what happening.
>
> i have a file(clob.txt) of size 4992680. i use the following command
>
> dd count=1 bs=1047142 if=clob.txt of=out.txt
> 1+0 records in
> 1+0 records out
>
> now i do ls -al out.txt
> -rw-r--r-- 1 miguser mig 1047142 Oct 26 16:43 out.txt
>
> When i open this file using some editor like EditPlus, it and when i do
> select all, the number of bytes shown are 1098101.
>
> In unix command shell it shows the size as 1047142 and when i open and
> check the file size its 1098101. Here i am getting some bytes extra.
>
> I am unable to figure out whats the problem?
>
> Thanx
>


This is not a problem of dd. It's a problem of your editor.
1. It's a reeeeeeally bad idea to count the exact size of a text file
with an Editor. There're a lot of symbols, which may be counted wrong.
(tabs, newline etc.). You should trust what your filesystem tells you.
(ls -al)

2. If you saved your testfile with the editor and than get wrong size.
Than your editor may have convert the newlines from UNIX to DOS without
asking. In a UNIX Text file LF stands for newline, while a dos textfile
uses CR+LF. This is a great example, why one shouldn't use some crappy
windows editor for Unix programming.

cheers
Luotao Fu
pankaj_wolfhunter@yahoo.co.in

2005-10-26, 6:01 pm

hey thanx for reply. I got it what i want.
thanx again

jussij@zeusedit.com

2005-11-23, 7:51 am

> This is a great example, why one shouldn't use some
> crappy windows editor for Unix programming.


And any decent windows editor should be able to handle both
text file types:

http://www.zeusedit.com/features.html

Jussi Jumppanen
Author: Zeus for Windows

Protocol Droid

2005-11-23, 7:51 am

jussij@zeusedit.com wrote...
>
> And any decent windows editor should be able to handle both
> text file types:
>
> http://www.zeusedit.com/features.html
>
> Jussi Jumppanen
> Author: Zeus for Windows


I didn't see any Release Notes. It'd be nice to know what the Known
Issues with Zeus are before considering changing editors.

--
"If you want peace, work for justice." (H.L. Mencken 1880-1956)
jussij@zeusedit.com

2005-11-23, 5:54 pm

> I didn't see any Release Notes.

The installer copies a history.txt file to the Zeus install
directory and this file list the major changes made to the
3.x version of the software.

As to know issues, I don't think there are any known issues?

There are always features that could be added or functionality
that could be improved, but in general Zeus is very stable.

It has been in continually development throught out the 1.x, 2.x
and now 3.x versions, which spans a period of some 10 years, so
there has been plenty of time to iron out all the bugs

> It'd be nice to know what the Known Issues with Zeus are
> before considering changing editors.


The shareware version runs fully functional for 45 days so it
possible to actually see what Zeus can and can not do.

Jussi Jumppanen
Author: Zeus for Windows IDE
http://www.zeusedit.com

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com