LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-08-2010, 11:30 PM   #1
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,520

Rep: Reputation: 51
dd command


GNU/Linux kernel 2.6

Hi:
what's wrong with the following command?:

dd if=/home/semoi/foo.html count=5000 bs=1 of=/home/semoi.foo1

This command has introduced strange chars. Why?
Any hint will be welcome.
 
Old 03-09-2010, 12:01 AM   #2
sohail0399
Member
 
Registered: Oct 2008
Location: Pakistan, Islamabad
Distribution: CentOS, Fedora, Solaris
Posts: 154

Rep: Reputation: 23
when you cat this file /home/semoi.foo1 then it shows strange characters.
this is the same cases for word or excel sheet because the data is encrypted.

if you make file in any text editor and save it and use dd to copy then copied file will show you same character as it is in the initial file.
 
Old 03-09-2010, 03:05 AM   #3
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,520

Original Poster
Rep: Reputation: 51
For me, a any file is a sequential string of bytes, encryption or no encryption. There should be a program, and I can do one, which limits itself to copy input to output byte by byte. I can't believe what you say.

Enrique.
 
Old 03-09-2010, 03:19 AM   #4
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
What are these so called "strange chars"? Can you provide the input and output files?

Evo2.
 
Old 03-09-2010, 03:33 AM   #5
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,520

Original Poster
Rep: Reputation: 51
How do I send the files?
 
Old 03-09-2010, 03:36 AM   #6
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671Reputation: 671
How long is the html file?

Why are you using dd to copy an html file?
Provide a sample from the file and the `strange' characters.
 
Old 03-09-2010, 03:36 AM   #7
giammy
Member
 
Registered: Feb 2010
Posts: 36

Rep: Reputation: 20
Quote:
Originally Posted by ENRIQUESTEFANINI View Post
GNU/Linux kernel 2.6

Hi:
what's wrong with the following command?:

dd if=/home/semoi/foo.html count=5000 bs=1 of=/home/semoi.foo1

This command has introduced strange chars. Why?
Any hint will be welcome.
Hi,

the input file size is exactly 5000 bytes?
that command copies 5000 bytes (or multiples): i do not know
what it does if the file is smaller (or its size is not
a multiple of 5000 ... perhaps adds random chars :-)

bye
giammy

P.S: I usually use cp to copy normal files, dd just for devices
 
Old 03-09-2010, 03:41 AM   #8
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
Quote:
Originally Posted by ENRIQUESTEFANINI View Post
How do I send the files?
Use the attach files option when writing a post (I assume, I've never done it).

Evo2.
 
Old 03-09-2010, 03:57 AM   #9
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,520

Original Poster
Rep: Reputation: 51
Input file is 7.5GB and I want to split it into two equal halves. 'split' I suspect is too slow for this. The html was just an example, but gave me the opportunity to see what dd can do to my 7.5GB file.

bash-3.1$ ls -l juan juan1
-rw-r--r-- 1 root root 13486 2010-03-09 02:38 juan
-rw-r--r-- 1 root root 8486 2010-03-09 02:14 juan1

Input file (first few bytes):
bash-3.1$ hexdump juan
0000000 213c 4f44 5443 5059 2045 5448 4c4d 5020
0000010 4255 494c 2043 2d22 2f2f 3357 2f43 442f
0000020 4454 5820 5448 4c4d 3120 302e 5420 6172
0000030 736e 7469 6f69 616e 2f6c 452f 224e 2220
0000040 7468 7074 2f3a 772f 7777 772e 2e33 726f
0000050 2f67 5254 782f 7468 6c6d 2f31 5444 2f44

Output from dd if=juan count=5000 bs=1 of=juan1
bash-3.1$ hexdump juan1
0000000 6172 635f 6d6f 6970 616c 5f72 6e75 705f
0000010 6f72 7267 6d61 5f61 6e65 6c5f 6e69 7875
0000020 2022 6c63 7361 3d73 7422 636f 3e22 6143
0000030 7072 7465 2061 6f6c 6163 206c 6170 6172
0000040 6320 6d6f 6970 616c 2072 6e75 7020 6f72
0000050 7267 6d61 2061 6e65 4c20 6e69 7875 2f3c
0000060 3e61 2f3c 7073 6e61 3c3e 642f 7669 3c3e
0000070 6c2f 3e69 3c0a 696c 6320 616c 7373 223d
0000080 656c 6576 326c 3e22 643c 7669 6320 616c

I do not any relationship between these two dumps!
 
Old 03-09-2010, 04:04 AM   #10
giammy
Member
 
Registered: Feb 2010
Posts: 36

Rep: Reputation: 20
Quote:
Originally Posted by ENRIQUESTEFANINI View Post
Input file is 7.5GB and I want to split it into two equal halves. 'split' I suspect is too slow for this. The html was just an example, but gave me the opportunity to see what dd can do to my 7.5GB file.

...

I do not any relationship between these two dumps!
Hi,

me neither!

I tested the following:
Code:
/tmp $ cat test
hello world
/tmp $ dd if=test count=5000 bs=1 of=test1
12+0 records in
12+0 records out
12 bytes transferred in 0.000134 secs (89558 bytes/sec)
/tmp $ cat test1
hello world
/tmp $ diff test test1
/tmp $
it seems working.

Anyway, dd do not split files - i do not understand how you can use it
for your aim :-(
 
Old 03-09-2010, 04:08 AM   #11
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
Hmm, I'm not sure what the problem is, but this type of thing should work. Look here for example:

http://www.linuxquestions.org/questi...r-file-623159/

Evo2.
 
Old 03-09-2010, 04:37 AM   #12
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,520

Original Poster
Rep: Reputation: 51
Say giammy, why don't you run the same test with a HTML file? And let me know.
 
Old 03-09-2010, 04:48 AM   #13
giammy
Member
 
Registered: Feb 2010
Posts: 36

Rep: Reputation: 20
Quote:
Originally Posted by ENRIQUESTEFANINI View Post
Say giammy, why don't you run the same test with a HTML file? And let me know.
Hi,

in my experience bytes are bytes and dd works :-)
anyway:

Code:
/tmp/Skybelts.it $ cat index.html 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>test</title>
<meta http-equiv="refresh" content="0;url= Skybelts.it.html" />
</head>
<body>
All Works!
</body>
</html>
/tmp/Skybelts.it $ dd if=index.html count=5000 bs=1 of=index1.html 
338+0 records in
338+0 records out
338 bytes transferred in 0.002708 secs (124817 bytes/sec)
/tmp/Skybelts.it $ cat index1.html 
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>test</title>
<meta http-equiv="refresh" content="0;url= Skybelts.it.html" />
</head>
<body>
All Works!
</body>
</html>
/tmp/Skybelts.it $ diff index.html index1.html 
/tmp/Skybelts.it $
bye
giammy
 
Old 03-09-2010, 05:02 AM   #14
sohail0399
Member
 
Registered: Oct 2008
Location: Pakistan, Islamabad
Distribution: CentOS, Fedora, Solaris
Posts: 154

Rep: Reputation: 23
yes i have also tested it.
there may be difference because at dd you have defined of block size of 1 byte and number of blocks are 5000, so 5 kB is copied.
otherwise same data is copied either encrypted or not.
In my case, i was consider strange character encrypted data.


you can also verify it through md5sum command by verifying checksum.

its a good tutorial to understand dd command:
http://www.softpanorama.org/Tools/dd.shtml
 
Old 03-09-2010, 08:37 PM   #15
stf92
Senior Member
 
Registered: Apr 2007
Location: Buenos Aires.
Distribution: Slackware
Posts: 3,520

Original Poster
Rep: Reputation: 51
I must have made some mistake. Thanks giammy for your post. And sohail0399. The problem that gave rise to this thread
has been solved by another method. So I'll close the thread and good bye fellows.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to copy drive using dd and tee command parallely? source code of dd command mdfakkeer Linux - Software 1 02-10-2010 01:31 PM
URGENT! Is there any command to get a history command lines and time in SUSE Linux.? igsoper Linux - Software 5 06-25-2009 02:14 AM
Is there a single command to list all hardware installed (command line)? davee Linux - Hardware 6 02-28-2009 07:19 PM
LXer: The Linux Command Shell For Beginners: Fear Not The Command Line! LXer Syndicated Linux News 0 12-22-2008 06:30 PM
My error in mkisofs command to make a command line iso mg92865 Linux - Newbie 1 06-20-2008 11:43 AM


All times are GMT -5. The time now is 09:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration