Received: from gyw.com (gyw.com [209.55.67.177]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f47Hf6A05903 for ; Mon, 7 May 2001 13:41:06 -0400 (EDT) (envelope-from tjk@tksoft.com) Received: from smtp3.tksoft.com (smtp3.tksoft.com [192.168.50.56] (may be forged)) by gyw.com (8.8.8/8.8.8) with ESMTP id LAA25074; Mon, 7 May 2001 11:10:07 -0700 Received: (from tjk@tksoft.com) by smtp3.tksoft.com (8.8.8/8.8.8) id JAA11645; Mon, 7 May 2001 09:32:42 -0700 From: "tjk@tksoft.com" Message-Id: <200105071632.JAA11645@smtp3.tksoft.com> Subject: Re: Re: Need help with search-and-replace To: iharding@pakrat.com (Ian Harding) Date: Mon, 7 May 2001 09:32:42 -0700 (PDT) Cc: pgsql-sql@postgresql.org In-Reply-To: from "Ian Harding" at May 05, 2001 04:33:04 PM X-Info: None MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200105/49 X-Sequence-Number: 2850 I am sure someone already sent this reply and I missed it. Anyway, if I understand the original problem correctly, you want to find instances of "\t\t00:00:00" and "\t\t\t\t\t\t\t00:00:00", etc. and remove them. I hope this is generic enough so you can change it to fit your needs: echo "Start c 00:00:00crap here." | sed "s/\([^ ]*\)[ ]\+[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\(.*\)/\1\2/g" This will find an instance of "nn:nn:nn" only when preceded by more than one tab. Perl is easier to read, so here is a perlish version: echo "Start c 00:00:00crap here." | {perlish} "s/([^\t]*)[\t]+\d\d:\d\d:\d\d(.*)/$1$2/g" Troy > > There are oh-so-many ways, as I am sure people will tell you. regular > expressions are the most wonderful things for such a task. I am comfortable > with tcl, so I would read the file into a tcl variable and use 'regsub -all > {\t700:00:00} $instring {} outstring'. > > There are unbelievably simple, unvbelievably fast ways to do this in one line > from the shell using sed, but I don't speak sed. I suspect someone will hook > you up with some basic sed. > > Try this in Windows. Visual Basic can use regular expressions, but you have to > instantiate a regular expression object, then execute one of it's methods to do > anything. Ugh. > > Ian > > Josh Berkus wrote: > > > Folks, > > > > I need to strip certain columns out of my pgdump file. However, I > > can't figure out how to use any Unix-based tool to search-and-replace a > > specific value which includes a tab character (e.g. replace "{TAB}7 > > 00:00:00" with "" to eliminate the column). > > > > RIght now, I'm copying the file to a Win32 machine and using MS Word > > for the search-and-replace, but I'm sure there's got to be a better way > > ... *without* learning VI or Emacs. Help? > > > > -Josh > > > > ______AGLIO DATABASE SOLUTIONS___________________________ > > Josh Berkus > > Complete information technology josh@agliodbs.com > > and data management solutions (415) 565-7293 > > for law firms, small businesses fax 621-2533 > > and non-profit organizations. San Francisco > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 4: Don't 'kill -9' the postmaster > > > ---------------------------(end of broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org >