>>>>> "Josh" == Josh Berkus <[EMAIL PROTECTED]> writes:

    Josh> Folks, I need to strip certain columns out of my pgdump
    Josh> file.  However, I can't figure out how to use any Unix-based
    Josh> tool to search-and-replace a specific value which includes a
    Josh> tab character (e.g. replace "{TAB}7 00: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

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Reply via email to