Find the answer to your Linux question:
Results 1 to 4 of 4
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Dropping special characters


    I'm trying to drop the character ^M from my piped command, however, I can't seem to get it to drop.

    In one terminal window, I am running

    echo -en "adc read 0\r" > /dev/ttyACM0

    which makes my device send back some results with numbers to the same port. To read the returned value, I am in a separate window I am running

    cat -v < /dev/ttyACM0 | grep -v ">"

    function that is already cleaning up some of the results, but still allowing ^M to come back. I have tried dropping all but numbers by expanding my cat to

    cat -v < /dev/ttyACM0 | grep -v ">" | tr -dc '[:alnum:]'

    but no luck.

    I'm open to ideas on how to drop the two characters that I don't want to see.

  2. #2
    you mean the literal string '^M'?
    why don't you want to see it?
    how did you try to filter it?
    I am not a "Linux Guru"! Get off me! The Forum software won't let me change it!
    How to ask smart questions | Don't be a Help Vampire | How to Use Code Tags
    You can post a link by removing "http://www." from it.

  3. #3
    Quote Originally Posted by nihili View Post
    you mean the literal string '^M'?
    why don't you want to see it?
    how did you try to filter it?
    Yes, I don't want to see it since I will take the value after it and calculate a value as part of a bash script.

    I tried dropping the ^M with the last section of the command. I've tried various sed and tr.

  4. $spacer_open
    $spacer_close
  5. #4
    Code:
    echo 'asdasd^Masdasd'| sed 's/\^M//g'
    I am not a "Linux Guru"! Get off me! The Forum software won't let me change it!
    How to ask smart questions | Don't be a Help Vampire | How to Use Code Tags
    You can post a link by removing "http://www." from it.

Posting Permissions

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