#!/bin/bash # # Martin Lomas, Graham Dicker # Version='v0.01 2010-08-03' # # Made available under the GPLv3 license # ProgName='bb: "Byte Blip"' # # Very naive program using "dd" for modifying a single byte in a file. # Modify default offset "os", change_from "a" and change_to "b" as required: os="54" a="$( echo -e "\001" )" b="$( echo -e "\006" )" # Run as follows: # # ./bb # ./bb # # For version and copyleft: # ./bb -v # # If out file is not given, the input file will be overwritten. If it fails, # you may lose data. # # # Copyright=' Copyright (C) 2010 martin Lomas' # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . # if [ "X$1" == "X-v" ] then echo echo "$ProgName" echo echo "$Version" echo echo "$Copyright" echo echo "This program comes with ABSOLUTELY NO WARRANTY." echo "This is free software, and you are welcome to redistribute it" echo "under certain conditions. For details, see:" echo "http://www.gnu.org/licenses/gpl-3.0.txt" echo exit fi f="$1" fout="$2" if [ -f "$f" ] then if [ -n "$fout" ] then cp "$f" "$fout" || exit -1 f="$fout" fi [ "$( dd bs=1 count=1 skip="$os" if="$f" )" == "$a" ] && echo "$b" | dd bs=1 count=1 seek="$os" conv=notrunc of="$f" exit fi # Must be an error condition or help: echo "Usage: bb -v | file [ outfile ]"