![]()
Linux, Unix, /etc/$ To set up this Linux system, do I really have to type long,
cryptic, frequently inconsistent and undocumented commands with
occasional long strings of hex digits?
# Yeah. You got a problem with that?
|
Sponsored links (requires javascript):
#!/bin/ksh
#chunksort: sort multi-line records (record separator single blank line)
ctrla=`echo a | tr a '\001'`
files=""
sortopts=""
# parse command line args
while :
do
case "$1" in
"") break ;;
-a) sortopts="$sortopts -t$ctrla" ;;
-o) echo "`basename $0` quitting: I don't have an -o option." 1>&2
exit 1 ;;
-[Tyz]) sortopts="$sortopts $1 $2"
shift ;;
[-+]*) sortopts="$sortopts $1" ;;
*) files="files $1" ;;
esac
shift
done
# replace format, do the sorting, restore format
sed -n '
/^$/ {
x
s/'$crtla'$//
p
b
}
H
g
s/\n//
s/$/'$ctrla'/
h' $files |
sort $sortopts |
sed "
s/$ctrla/\\
/g
G"