Last Char on a line

I have a file that cat -e shows that the last char of each line is M-J.
(" Non-ASCII characters (with the high bit set) are printed as `M-' (for meta) followed by the character for the low 7 bits.)
Now, I can remove this with sed 's/.$//' but, what is char M-J, if I wanted to remove this with the actual char in sed (instead of using the wildcard ".$") ?

Glad it worked. At first I was sure the M-J was somehow really ^M so I thought it was just a DOS/Windows CRLF file, especially since the 0xCA character didn't make any sense to me. Now I see (thanx to Niel!) that the character is the non-breaking space of the MacRoman character set. Still, not a common thing to see.
BTW, this example uses a bash feature to insert the 0xCA character into the command line, so it probably won't work with other shells. If you put this line into a shell script, be sure to add
"#!/bin/bash" at the top.
Quoting special characters in the shell can be tricky and you don't show your entire command line, so I can't be sure if you had quoting around what you show. I showed the entire command, which worked for me, so I assume the difference is accounted for quoting that you didn't show.

Similar Messages

  • Read last char of a String

    I have the following code that functions like a basic RPN calculator:
    public class Main {
         * @param args the command line arguments
         static public ArrayList<Double> stack = new ArrayList<Double>();
         static double numberInput;
         static double answer;
         static String operation;
    //Prints Welcome screen, initialized checkforInput
         public static void main(String[] args) {
             System.out.println();
             System.out.println("Welcome to RPNCalc by theCoffeeShop()");
             checkForInput();
    //Checks for input, redirects to appropriate method
         public static void checkForInput() {
             Scanner reader = new Scanner(System.in);
          String input = reader.nextLine();
             if(isDouble(input) == true) {
                double number = Double.parseDouble( input );
                stack.add(0, number);
                repeat();
             } else {
                operation = input;
                operation();
    //Processes numeric operations
         public static void operation () {
             if(operation.equals("+")) {
                 answer = stack.get(1)+stack.get(0);
                 stack.add(0, answer);
                 System.out.println(answer);
                 repeat();
             } else if (operation.equals("-")) {
                 answer = stack.get(1)-stack.get(0);
                 stack.add(0, answer);
                 System.out.println(answer);
                 repeat();
             } else if (operation.equals("*")) {
                 answer = stack.get(1)*stack.get(0);
                 stack.add(0, answer);
                 System.out.println(answer);
                 repeat();
             } else if (operation.equals("/")) {
                 answer = stack.get(1)/stack.get(0);
                 stack.add(0, answer);
                 System.out.println(answer);
                 repeat();
             } else {
                 System.out.println("Incompatible operation");
                 repeat();
    //Called when ready to recheck for input
         public static void repeat() {
             checkForInput();
    //Checks if string is double
         public static boolean isDouble( String input )
            try
                Double.parseDouble( input );
                return true;
            catch(Exception e)
               return false;
    }To perform a basic operation (5+2), you would do the following
    5
    enter
    2
    enter
    (plus)
    enter
    Computer prints 7.
    I would like it to function like this:
    5
    enter
    2(plus)
    enter
    Computer prints 7.
    To do this, I have to be a be to split a string into 2 parts, the operation and the number. I think I could do this with a StringBuffer, but How to read the LAST char of a StringBuffer, instead of just a specific char? If there is a way to do it w/out a StringBuffer, I'm open to suggestions.

    Hint:
    The last character of a String (or StringBuilder or StringBuffer, etc.) is at the index (length_of_string - 1).
    Are you sure you're supposed to solve the problem this way? Usually homework assignments of this sort involve writing a whole parser.

  • How to delete the last char in a String?

    i want to delete the last char in a String, but i don't want to convert the String to a StringBuffer or an array, who knows how to do?

    Try it in this way
    String MyString = "ABCDEF";
    MyString = MyString.substring(0,MyString.length()-1);

  • Cutting last char in the XI

    hello experts
    I have a scenario RFC2WS and sending
      <?xml version="1.0" encoding="UTF-8" ?>
    - <rfc:ZRFC_POLICY_OR_INSURANCE xmlns:rfc="urn:sap-com:document:sap:rfc:functions">
      <PASSWORD>kf001</PASSWORD>
      <USERNAME>kfirg001</USERNAME>
      </rfc:ZRFC_POLICY_OR_INSURANCE>
    but in the XI I am recieving
      <?xml version="1.0" encoding="UTF-8" ?>
    - <rfc:ZRFC_POLICY_OR_INSURANCE xmlns:rfc="urn:sap-com:document:sap:rfc:functions">
      <PASSWORD>kf00</PASSWORD>
      <USERNAME>kfirg00</USERNAME>
      </rfc:ZRFC_POLICY_OR_INSURANCE>
    it is always cutting the last char in the username\password. in the RFC it is defined as a String.
    I couldnt find out why it is cutting the last char and help would be great.
    Thanks
    Kfir

    Hi,
    Is it possible for you to send it with Filed type as CHAR instead of String..
    In RFC source code you could handle this kind of conversion.
    Try with CHAR...instead of string.
    Thanks
    Swarup

  • Character mode report cuts off last character on a line

    Reports 9i, Windows 2003 Server. Printing character mode reports to IBM 6400 printer. I have a variable text column (multi line) and randomly the last character on a line gets cutoff. I'm using Courier 10 as my font. It is only 1 character that ever cuts cutoff. Any ideas? I'm desperate.
    Tom

    Hi,
    change the reports height& width for landscape /portait.
    and go to edit margin in layout.
    see the layout and move to left if it has lot of gap in left side.
    we can get correct output if the right side border is upto 8.2.
    try with this.
    --Basava.s                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Remove last char

    Ok i am trying to make just a simple calculator program for a class. I am trying to get the backspace button to work. How would i delete the last char in the string.

    use a substring, the last char. will be:
    myString.length
    that will give you the length and from that you know what the last char. is

  • Deleting the last char of a string

    How can I Delete the last char of a string???
    example:
    asd@fdg@vvdfgfd@gdgdfgfd@gdfgdf@
    I want delete the last @!
    Tks in advance!

    hi,
    try this:
    lv_count = strlen(string).
    lv_count_last = lv-count - 1.
    replace string+lv_count_last(lv_count) in string by ' '.
    This should work.
    thnx,
    ags.
    Edited by: Agasti Kale on Jun 4, 2008 9:03 PM

  • How to remove last char in a string by space

    I have to implement backspace application(remove a last char in a string , when we pressed a button).
    for ex: I enter the no
    1234
    instead of 1236
    So when i press a button on the JWindow... it should display
    123
    so that i can enter 6 now.
    I tried to display the string "123 " instead over "1234" but it is not working when the no background is specified. but works fine when a background color is specified.
    The string is displayed as
    Graphics2D g = (Graphics2D)window.getGraphics();
    AttributedString as = new AttributedString(string, map);
    g.drawString(as.getIterator(),x,y);
    In the map, the background is set to NO_BACKGROUND.
    Thanks and regards

    Deja vu. I saw this kind of post before, and I'm sure
    it was today.http://forum.java.sun.com/thread.jspa?threadID=588110&tstart=0
    Here it is.

  • Deleting last char in a string...

    I have a string that is created as follows: strBuffer += k.getKeyChar();(k is KeyPressed ...KeyEvent) How can I delete the last Char in the string strBuffer?

    Hi
    // simply substring
    if (strBuffer.length() > 1)
        strBuffer = strBuffer.substring(0, strBuffer.length()-1);
    // you may also use
    if (strBuffer.length() > 1)
        StringBuffer buffer = new StringBuffer(strBuffer).
                                   deleteCharAt(strBuffer.length()-1);
        strBuffer = buffer.toString();
    }I've not tested the above code myself & I've written the above code on the go after reading your query. The above code definitely work & help you.
    Regards,
    JPassion

  • Compare the last Char to the First Char in a Sting

    Hello, this should be easy but I'm having problems so here goes.
    I get the user to input a Stirng and I want it to compare the last Char to the first Char. I have writen this but StartWith can take a Char?
    public static void main(String[] args) {
            // TODO code application logic here
            String strA = new String();
            int length = 0;
            char lastLetter;
            System.out.println("Please input your first String: ");
                   strA = EasyIn.getString();
                 length = strA.length()-1;
                   lastLetter = strA.charAt(length);
           if( strA.endsWith(lastLetter))
                System.out.println("The first letter matches the last");
           else
                       System.out.println("They Don't match");
    }I have tried lastLetter.endsWith(strA) but that dosn't work some thing to do with it not taking Char
    From reading you can go strA.startWith("R") and that would look for R but you can't put a char in that would be a single letter.
    I also tried to lastletter to a string but then charAt wouldn't work.

    fixed it I used substring as its a string object any one recomend a better way let me know
    public static void main(String[] args) {
            // TODO code application logic here
            String strA = new String();
            int length = 0;
            String lastLetter;
            System.out.println("Please input your first String: ");
                   strA = EasyIn.getString();
                 length = strA.length()-1;
                   lastLetter = strA.substring(length);
           if( strA.startsWith(lastLetter))
                System.out.println("The first letter matches the last");
           else
                       System.out.println("They Don't match");
    }

  • Finding last char in the string

    Hi
    i need to find out whether the last char of a string is '/' (forward slash). please let me know if there's a FM to do that. Other post me the logic for this ASAP.
    thanks

    len = strlen(char).
    len = len - 1.
    if char+len(1) = '/'.
      *write ur code
    endif.
    chk this code
    REPORT ychatest.
    DATA : str(5) VALUE '123/',
           len TYPE i.
    len = STRLEN( str ).
    len = len - 1.
    IF str+len(1) = '/'.
      WRITE : '/ found'.
    ENDIF.
    <b>Reward points if helpful and close thrad if solved</b>
    Message was edited by: Chandrasekhar Jagarlamudi

  • Can i use the char (defined as line iteam dim) in  Aggregates

    Hi
    I am maintaining aggregates on cube. can i use char which is defined as line iteam   dimenstion.if i use  how will be the effect.
    thanks
    Shaliny

    Hi,
    of course you can use it!
    The behaviour is the same than with the other characteristics: you will have as many records as DISTINCT ocurrences of the combination of all CHARS you have included in your aggregate.
    I suggest to first create your aggregate with a fixed value on another characteristic so you can have a feeling about how many records it will have and how long it will take to create it.
    In general if you have flagged your char in a line itm DIM it means that this CHAR has very high cardinality (nearly the same number of records than the fact  table itself) therefore it wouldn't make sense to include it in a ggregate except if your filter it for particluar fixed value.
    The only difference you have with this line itm DIM is that there is no DIM table as such; the chars is accessed firectly from the cube fact(s) table. This will be the same for your aggregate (no aggr dim table created, access form your aggr fact(s) tables).
    hoping this help...
    Olivier.

  • Remove last char of string

    Hi Guys
    How can I remove the last char of a String ?

    With [the substring method|http://java.sun.com/javase/6/docs/api/java/lang/String.html#substring(int,%20int)] .

  • User defined function for getting last string in the line

    Hi Experts,
    I am not java expert, can anyone give me user defined function for getting last string in the line.
    for example if the source field is "NEW ARBOUR SQUARE"  i want to pass to target field only last string that is "SQUARE"
    please help me out of this.
    Kind Regards.
    Praveen.

    You don't even need a UDF for this. In the graphical editor look for the standard functions and once you do a scroll over on 'text functions; you will find what you are looking for.
    Just a piece of advice, try keeping UDF's to minimum unless really required or it is complicated without it.
    regards

  • Split Last Word into New Line

    Hello,
    Any pointers to below :-
    When entering data in column of size say 4000 the last word in the line should not be split if it cud not fit,
    if the last word does not fit then it should appear in new line and cursor should be placed at last of the word (if its last word of sentence).
    Note that multiline is set to yes and item is text item with form layout, although i have one solution but its not the best one.
    Thoughts are appreciated if there is any built in property for this or some other way?
    Forms version 10g
    Database 9i
    br
    atul

    Hello,
    This could be the starting point of an algorythme:
    SQL> set serveroutput on
    SQL>
    SQL> DECLARE
      2    LC$c    VARCHAR2(1000);
      3    v       VARCHAR2(1000);
      4    LN$MAX  PLS_INTEGER := 20 ;
      5    i       PLS_INTEGER;
      6  BEGIN
      7    LC$c := 'Here is a text to test the split of a large sentence into multiple sub fields';
      8    LOOP
      9      v := SUBSTR(LC$c, 1, LN$MAX);
    10      i := INSTR(v,' ',-1);
    11     IF i > 0 AND i < LENGTH(v) THEN
    12       v := SUBSTR(v,1,i);
    13       LC$c := SUBSTR(LC$C,i+1,1000);
    14     ELSE
    15       LC$c := SUBSTR(LC$C,LN$MAX+1,1000);
    16     END IF ;
    17     DBMS_OUTPUT.PUT_LINE('[' || v || ']');
    18     EXIT WHEN LENGTH(LC$C) = 0  OR LENGTH(LC$c) <= LN$MAX; 
    19    END LOOP;
    20    IF LENGTH(LC$c) > 0 THEN
    21      DBMS_OUTPUT.PUT_LINE('[' || LC$C || ']');
    22    END IF ;
    23  END;
    24 
    25  /
    [Here is a text to ]
    [test the split of a ]
    [large sentence into ]
    [multiple sub fields]
    Procédure PL/SQL terminée avec succès.Francois

Maybe you are looking for

  • Delivery Notes

    What is a delivery note? What is its meaning and which are the transactions for it? Edited by: Wilian Segatto on Jan 22, 2010 4:13 PM

  • My I phone was down loading the latest update to O S 7.o and it froze showing an I tunes icon and the wire connection to the charger. My phone is not working now.

    My I phone was down loading the latest update to OS 7.0 and it froze showing an I tunes icon, and an arrow pointing to the cord used to charge and download. I can't use the phone now its frozen in this screen.

  • ROWID in Raptor - Question

    Hi, Just a quick question. When I select the rowid from sqlplus, I get AAAF8AAAFAAAAGIAAA , however, when I select the same row from Raptor, I am getting this - oracle.sql.ROWID@cfd22a. Why is this difference? Is there any setting that I need to/can

  • Runtime error in bsp

    Hi ,      I am facing  BSP runtime problem Runtime Errors:        ITAB_ILLEGAL_SORT_ORDER  Short txt:                                                                             Error when inserting or changing in a sorted table    pls help me , its

  • Whats the difference between these versions of photoshop?

    First of all to make things clear I want to mention this first that I lives in Pakistan and Adobe doesn't support my region so in order to buy the Adobe Photoshop CC I have to contact the authorized resellers, after contacting them and asking for a i