UNIX / Linux Shell Script To Copy Disk (DOS Like DISKCOPY Command)

Write a shell script to implement the DISKCOPY command of DOS command, which allows a user to copy the complete contents of a diskette to another diskette. Under UNIX / Linux we can use dd command to copy disk.

dd is use to copy a file, converting and formatting according to the options. Since everything is considered as a file under Linux / UNIX you can write files to a diskette with dd command itself. Linux disk copy done using /dev/fd0 (first floppy drive). You can easily make Linux disk backup with dd command.

#!/bin/bash
# Shell Script to copy the complete  contents of a diskette to another diskette
# under UNIX / Linux.
# -------------------------------------------------------------------------
# Copyright (c) 2007 nixCraft project <http://cyberciti.biz/fb/>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------
 
SOURCE="$1"
DEST="$2"
if [ $# -le 1 ]; then
        echo "Copies the contents of one floppy disk to another."
        echo "diskcopy /dev/fd0 /dev/fd1"
        echo "diskcopy /dev/fd0 /tmp/floppydisk.img"
        exit 1
fi
 
if [ !  -b $SOURCE ]; then
        echo "Error - Floppy device $SOURCE does not exits."
        exit 2
fi
 
if [ !  -b $DEST ]; then
        echo "Error - Floppy device $DEST does not exits."
        exit 2
fi
 
echo "Enter disk in $SOURCE and press [Enter] key..."
read enterKey
 
dd if=$SOURCE of=$DEST
Get the latest tutorials on SysAdmin, Linux/Unix, Open Source, and DevOps topics:
CategoryList of Unix and Linux commands
File Management cat
Firewall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilities dig host ip nmap
OpenVPN CentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Manager apk apt
Processes Management bg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searching grep whereis which
User Information groups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPN CentOS 8 Debian 10 Firewall Ubuntu 20.04
0 comments… add one

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.