[ale] Quick substitution question

Fletch fletch at phydeaux.org
Wed Dec 13 10:44:34 EST 2000


>>>>> "Armsby" == Armsby John-G16665 <John.Armsby at motorola.com> writes:

    Armsby> I have a large file which has tab delimited information
    Armsby> per line.  Can some blast out a quick vi command to
    Armsby> substitute a pipe | for the tab \t ?

    Armsby> This does not work.... :%s/\t/|/g

:%s,^VTAB,|,g

        Where ^V is ctrl-v and then hit the TAB key.

    Armsby> I am trying to make this simple for others in my group.  I
    Armsby> would prefer not to use perl or awk, etc.  I know they can
    Armsby> do it but I am considering those who will follow me
    Armsby> here...

        Like perl -i.bak -pe 's,\t,|,g' foo is any more difficult? :)
Not to mention you get a backup copy without having to remember to cp
it yourself.  And if you just put it in their .zshrc/.bashrc/.kshrc, or 
even just a script in their path, as:

tab2pipe () {
  if [ $# -eq 0 ] ; then
    echo "usage: $0 file [file . . .]"
    return 1
  fi

  perl -i.bak -pe 's,\t,|,g' "$@"
}

        They don't need to remember anything.


-- 
Fletch                | "If you find my answers frightening,       __`'/|
fletch at phydeaux.org   |  Vincent, you should cease askin'          \ o.O'
770 933-0600 x211(w)  |  scary questions." -- Jules                =(___)=
                      |                                               U
--
To unsubscribe: mail majordomo at ale.org with "unsubscribe ale" in message body.





More information about the Ale mailing list