LDP/LDP/guide/docbook/abs-guide/exercising-dd.sh

22 lines
587 B
Bash
Raw Normal View History

2004-03-15 13:48:46 +00:00
#!/bin/bash
# exercising-dd.sh
# Script by Stephane Chazelas.
2006-12-20 21:11:55 +00:00
# Somewhat modified by ABS Guide author.
2004-03-15 13:48:46 +00:00
2011-08-29 23:59:19 +00:00
infile=$0 # This script.
outfile=log.txt # Output file left behind.
n=8
p=11
2004-03-15 13:48:46 +00:00
2006-12-20 21:11:55 +00:00
dd if=$infile of=$outfile bs=1 skip=$((n-1)) count=$((p-n+1)) 2> /dev/null
2011-08-29 23:59:19 +00:00
# Extracts characters n to p (8 to 11) from this script ("bash").
2004-03-15 13:48:46 +00:00
2011-08-29 23:59:19 +00:00
# ----------------------------------------------------------------
2004-03-15 13:48:46 +00:00
2011-08-29 23:59:19 +00:00
echo -n "hello vertical world" | dd cbs=1 conv=unblock 2> /dev/null
# Echoes "hello vertical world" vertically downward.
2008-11-23 22:43:47 +00:00
# Why? A newline follows each character dd emits.
2004-03-15 13:48:46 +00:00
2011-08-29 23:59:19 +00:00
exit $?