Loading ...
Sorry, an error occurred while loading the content.

Re: difference

Expand Messages
  • David Rock
    ... Do this with join: join -v1 bar foo foo.bar ... -- David Rock david@graniteweb.com
    Message 1 of 5 , Jan 1, 2003
    • 0 Attachment
      * Payal Rathod <payal@...> [2003-01-02 09:38]:
      > Hi all,
      > I have 2 problems.
      >
      > 1. I have 2 files foo and bar with a word on each line.
      > foo -> 5000 words
      > bar -> 2300 words.
      > Now I want to *find all the words in bar that are missing in foo* and
      > put them in 3rd file foo.bar.
      > ( So, foo.bar will have a maximum of 2300 words. )
      > (both the files are sorted)
      > Please remember I don't want words unique to file foo. I want words in
      > bar which are not in foo.

      Do this with join:
      join -v1 bar foo > foo.bar

      > 2. In another file, I have few lines seperated by a single tab. Now I
      > want to delete all the lines ( and NOT just the tab ) which start with
      > a tab. I tried :1,$/^^I/d but managed to delete just one line at a time.
      > Can someone help me on this?

      :g/^\t/d

      --
      David Rock
      david@...
    • John Culleton
      ... 1. If you have a *nix machine I would use the standard utilities, such as diff, uniq, sort and so on in some combination. I do this all the time in similar
      Message 2 of 5 , Jan 2, 2003
      • 0 Attachment
        On Thursday 02 January 2003 04:08, Payal Rathod wrote:
        > Hi all,
        > I have 2 problems.
        >
        > 1. I have 2 files foo and bar with a word on each line.
        > foo -> 5000 words
        > bar -> 2300 words.
        > Now I want to *find all the words in bar that are missing in foo* and
        > put them in 3rd file foo.bar.
        > ( So, foo.bar will have a maximum of 2300 words. )
        > (both the files are sorted)
        > Please remember I don't want words unique to file foo. I want words
        > in bar which are not in foo.
        >
        > 2. In another file, I have few lines seperated by a single tab. Now I
        > want to delete all the lines ( and NOT just the tab ) which start
        > with a tab. I tried :1,$/^^I/d but managed to delete just one line at
        > a time. Can someone help me on this?
        >
        > Thanks a lot for the help in advance and bye.
        > With warm regards,
        > -Payal

        1. If you have a *nix machine I would use the standard utilities, such
        as
        diff, uniq, sort and so on in some combination. I do this all the time
        in similar problems. I wouldn't use Vim.

        2. Don't know :-)

        John Culleton
        Able Indexers and Typesetters
        Rowse Reviews
        Culleton Editorial Services
        http://wexfordpress.com
      • Gary Holloway
        / FROM: Payal Rathod , Jan 2 9:38 2003 ... If you re on Unix, you can use: comm -13 foo bar foo.bar -gary ... END: Payal Rathod
        Message 3 of 5 , Jan 2, 2003
        • 0 Attachment
          / FROM: Payal Rathod <payal@...>, Jan 2 9:38 2003
          | ABOUT: difference
          |
          | Hi all,
          | I have 2 problems.
          |
          | 1. I have 2 files foo and bar with a word on each line.
          | foo -> 5000 words
          | bar -> 2300 words.
          | Now I want to *find all the words in bar that are missing in foo* and
          | put them in 3rd file foo.bar.
          | ( So, foo.bar will have a maximum of 2300 words. )
          | (both the files are sorted)
          | Please remember I don't want words unique to file foo. I want words in
          | bar which are not in foo.

          If you're on Unix, you can use:

          comm -13 foo bar > foo.bar

          -gary

          |
          | 2. In another file, I have few lines seperated by a single tab. Now I
          | want to delete all the lines ( and NOT just the tab ) which start with
          | a tab. I tried :1,$/^^I/d but managed to delete just one line at a time.
          | Can someone help me on this?
          |
          | Thanks a lot for the help in advance and bye.
          | With warm regards,
          | -Payal
          |
          | --
          | Payal Rathod <payal at hotpop.com>
          | "Visit Linux Success Stories"
          | www.geocities.com/rpayal99
          |
          \ END: Payal Rathod
        • Michael Naumann
          ... You want one of the following ... HTH, Michael
          Message 4 of 5 , Jan 2, 2003
          • 0 Attachment
            >On Thursday 02 January 2003 04:08, Payal Rathod wrote:

            >> 2. In another file, I have few lines seperated by a single tab. Now I
            >> want to delete all the lines ( and NOT just the tab ) which start
            >> with a tab. I tried :1,$/^^I/d but managed to delete just one line at
            >> a time. Can someone help me on this?

            You want one of the following
            :1,$g/^^I/d note the g(lobal) , Read ":help :g"
            :%g/^^I/d % is equivalent to 1,$
            :g/^^I/d default range for g is %

            HTH, Michael
          Your message has been successfully submitted and would be delivered to recipients shortly.