Обсуждение: cat infile | translate all occurences of "NOT NULL" to ""
what command do I use to substitute all occurences of a certain string (say, "NOT NULL") with another arbitrary string, (e.g. "")? I've tried grep and tr, but can't figure it out. Thanks, Dan Browning Network & Database Administrator Cyclone Computer Systems
in vi you can type : and then 1,$s/oldstring/newstring/g where 1 means start from the first line, $ means until the end of the file, oldstring is what you want to replace, newstring is what you want to replace it with, and the g means do it globally throughout the file. e.g. 1,$s/NOT NULL//g should work Hope this helps Tamsin -----Original Message----- From: pgsql-novice-owner@hub.org [mailto:pgsql-novice-owner@hub.org]On Behalf Of Dan Browning Sent: 11 September 2000 15:16 To: pgsql-novice@postgresql.org; redhat-list@redhat.com; jsokel@mdsi-usa.com Subject: [NOVICE] cat infile | translate all occurences of "NOT NULL" to "" what command do I use to substitute all occurences of a certain string (say, "NOT NULL") with another arbitrary string, (e.g. "")? I've tried grep and tr, but can't figure it out. Thanks, Dan Browning Network & Database Administrator Cyclone Computer Systems
cat infile | sed 's/NOT NULL//g'
should do it as well ...
On Mon, 11 Sep 2000, Tamsin wrote:
> in vi you can type : and then 1,$s/oldstring/newstring/g
> where 1 means start from the first line, $ means until the end of the file,
> oldstring is what you want to replace, newstring is what you want to replace
> it with, and the g means do it globally throughout the file.
>
> e.g. 1,$s/NOT NULL//g should work
>
> Hope this helps
> Tamsin
>
> -----Original Message-----
> From: pgsql-novice-owner@hub.org [mailto:pgsql-novice-owner@hub.org]On
> Behalf Of Dan Browning
> Sent: 11 September 2000 15:16
> To: pgsql-novice@postgresql.org; redhat-list@redhat.com;
> jsokel@mdsi-usa.com
> Subject: [NOVICE] cat infile | translate all occurences of "NOT NULL" to
> ""
>
>
> what command do I use to substitute all occurences of a certain string (say,
> "NOT NULL") with another arbitrary string, (e.g. "")? I've tried grep and
> tr, but can't figure it out.
>
> Thanks,
>
> Dan Browning
> Network & Database Administrator
> Cyclone Computer Systems
>
>
Marc G. Fournier ICQ#7615664 IRC Nick: Scrappy
Systems Administrator @ hub.org
primary: scrappy@hub.org secondary: scrappy@{freebsd|postgresql}.org
The easiest thing is probably to use vi. Then write
:s/"NOT NULL"/""/gc
the `g' will do each occurence, and the `c' will ask
for confirmation. Once you are sure everything will
be fine, let it do `all'.
Otherwise, you can use `sed', but that is weird...
W
--- Dan Browning <danb@cyclonecomputers.com> wrote:
> what command do I use to substitute all occurences
> of a certain string (say,
> "NOT NULL") with another arbitrary string, (e.g.
> "")? I've tried grep and
> tr, but can't figure it out.
>
> Thanks,
>
> Dan Browning
> Network & Database Administrator
> Cyclone Computer Systems
>
__________________________________________________
Do You Yahoo!?
Yahoo! Mail - Free email you can access from anywhere!
http://mail.yahoo.com/