>>>>> "Josh" == Josh Berkus <josh@agliodbs.com> writes:
Josh> Folks, I need to strip certain columns out of my pgdump Josh> file. However, I can't figure out how to use
anyUnix-based Josh> tool to search-and-replace a specific value which includes a Josh> tab character (e.g. replace
"{TAB}700:00:00" with "" to Josh> eliminate the column).
Unix lives by the shell pipe. Set "exit on error", to avoid data loss
in case of "filesystem full", proceed by using "tr" to translate
single characters within the file to something more easily replacable,
do the replace with "sed", translate back using "tr", move over old
file, done:
---------------------------------------------------------------------------
#!/bin/bash
set -e -x
cat "$*" | \
tr '\t' '�' | \
sed -e 's/�7 00:00:00//g' | \
tr '�' '\t' | \
cat > x.$$
mv x.$$ "*"
---------------------------------------------------------------------------
(please don't kill me for the two "cat" operators, they serve no
purpose besides legibility).
so long,
Oliver