Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2013
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    remove characters that are different from ABCD in a file

    Hi guys!
    I have a text file, and I want to delete all the characters that are not A,B,C and D.
    For example if my file contain this 2 lines:
    ABCDEFGHIJ
    GHKLABC

    the new file will look like:
    ABCD
    ABC

    I am looking for an easy way.. ideas?

    Thanks,
    Pap




  2. #2
    Join Date
    Dec 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    If you remove all characters other than A, B, C, and D, that will not
    be the result; it will also remove the newline:
    Code:
    tr -dc 'ABCD' < "$file"
    The result will be:
    ABCDABC

    What you want is:

    Code:
    tr -dc 'ABCD\n' < "$file"

 

 

Similar Threads

  1. How to remove a directory recursively?
    By carbon333 in forum Command Line
    Replies: 4
    Last Post: 08-05-2012, 09:22 PM
  2. limited to 25000 characters to reply
    By enhu in forum Forum Assistance
    Replies: 2
    Last Post: 05-28-2012, 10:38 PM
  3. Remove Ubuntu and keep Grub.
    By floopy in forum General Linux
    Replies: 6
    Last Post: 05-04-2012, 08:00 AM
  4. Build your own special characters chooser
    By News in forum Linux News
    Replies: 0
    Last Post: 03-06-2012, 01:14 AM
  5. Remove files older than X
    By Rob in forum Command Line
    Replies: 1
    Last Post: 11-03-2011, 08:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
           








Check out Linux Central for Linux software and other goodies!





» Stats

Members: 3,536
Threads: 3,911
Posts: 9,420
Top Poster: Fred (1,486)
Welcome to our newest member, chrisbrow2

» Links



Powered by vBadvanced CMPS