[SOLVED] Why are control characters visible in text files??

Hi,
If I direct the output of 'ls' to a file like:
ls > file.txt
and open the file in a editor such as vi, joe or mousepad, it looks like this:
[[01;34m22x22[[0m
[[01;34m24x24[[0m
[[01;34m32x32[[0m
[[0mindex.theme[[0m
[[01;34mscalable[[0m
[[m
I just did the same thing on an old slackware box and no control characters are visible. The same for a recent LFS build. I realize I could probably pipe through dos2unix, but it shouldn't be happening anyway. Any input is appreciated.
Thanks
-Frank
Last edited by fianella (2007-10-24 10:37:00)

at the DOS prompt (sorry, old habits die hard :-) ) type
alias ls
and see what the results are.  Compare that against your slackware or lfs builds.  You will probably find that the color= option is different - most builds will not include the color ANSI sequences if you pipe the output, but if it says color=always the color codes will be included in the redirected file.
Assuming you find an alias for ls that forces color output, you need to find where that is taking place... in your ~/.bashrc file?  in /etc/profile.d?  And change that to alias ls='ls --color=tty' or something sensible like that.

Similar Messages

  • Removing the Control Characters from a text file

    Hi,
    I am using the java.util.regex.* package to removing the control characters from a text file. I got below programming from the java.sun site.
    I am able to successfully compile the file and the when I try to run the file I got the error as
    ------------------------------------------------------------------------D:\Debi\datamigration>java Control
    Exception in thread "main" java.util.regex.PatternSyntaxException: Illegal repet
    ition
    {cntrl}
    at java.util.regex.Pattern.error(Pattern.java:1472)
    at java.util.regex.Pattern.closure(Pattern.java:2473)
    at java.util.regex.Pattern.sequence(Pattern.java:1597)
    at java.util.regex.Pattern.expr(Pattern.java:1489)
    at java.util.regex.Pattern.compile(Pattern.java:1257)
    at java.util.regex.Pattern.<init>(Pattern.java:1013)
    at java.util.regex.Pattern.compile(Pattern.java:760)
    at Control.main(Control.java:24)
    Please help me on this issue.
    Thanks&Regards
    Debi
    import java.util.regex.*;
    import java.io.*;
    public class Control {
    public static void main(String[] args)
    throws Exception {
    //Create a file object with the file name
    //in the argument:
    File fin = new File("fileName1");
    File fout = new File("fileName2");
    //Open and input and output stream
    FileInputStream fis =
    new FileInputStream(fin);
    FileOutputStream fos =
    new FileOutputStream(fout);
    BufferedReader in = new BufferedReader(
    new InputStreamReader(fis));
    BufferedWriter out = new BufferedWriter(
    new OutputStreamWriter(fos));
         // The pattern matches control characters
    Pattern p = Pattern.compile("{cntrl}");
    Matcher m = p.matcher("");
    String aLine = null;
    while((aLine = in.readLine()) != null) {
    m.reset(aLine);
    //Replaces control characters with an empty
    //string.
    String result = m.replaceAll("");
    out.write(result);
    out.newLine();
    in.close();
    out.close();

    Hi,
    I used the code below with the \p, but I didn't able to complie the file. It gave me an
    D:\Debi\datamigration>javac Control.java
    Control.java:24: illegal escape character
    Pattern p = Pattern.compile("\p{cntrl}");
    ^
    1 error
    Please help me on this issue.
    Thanks&Regards
    Debi
    // The pattern matches control characters
    Pattern p = Pattern.compile("\p{cntrl}");
    Matcher m = p.matcher("");
    String aLine = null;

  • Removing unwanted control characters in exported text files

    I am currently evaluating Crystal Reports 2008 to determine applicability to our requirements. I need to export data files to continuous text to be read by other application software. I have successfully created the files but have what I believe to be page feed or end-of-page control characters (small rectangles) in the output. Can someone enlighten me as to how I can suppress or remove these control characters?

    In the export to text options enter 0 for the number of lines per page. This will produce an unpaginated text document without the page control markers.

  • Why are certain characters invalid in SharePoint file names/folders?

    Hello. I know which characters are not accepted in file names, but someone asked me today why that was and I was stumped! Does anyone know?

    They are usually invalid because the have a special meaning to the operating system or to URLs. For example the slash "/" is not allowed because it is used as a seperator in a URL.  (http://yourserver/yousite/somepage.htm).
    Greater than (>) and less than (<) are not allowed as they are used to redirect output from a DOS command to a file ( DIR *.doc > listofwordfiles.txt )
    So each reserved character has a special use somewhere... in DOS, in HTTP, in SharePoint, etc.
    Mike Smith TechTrainingNotes.blogspot.com
    my SP customization book

  • Reading characters from a text file into a multidimensional array?

    I have an array, maze[][] that is to be filled with characters from a text file. I've got most of the program worked out (i think) but can't test it because I am reading my file incorrectly. However, I'm running into major headaches with this part of the program.
    The text file looks like this: (It is meant to be a maze, 19 is the size of the maze(assumed to be square). is free space, # is block, s is start, x is finish)
    This didn't paste evenly, but thats not a big deal. Just giving an idea.
    19
    5..................
    And my constructor looks like follows, I've tried zillions of things with the input.hasNext() and hasNextLine() to no avail.
    Code:
    //Scanner to read file
    Scanner input = null;
    try{
    input = new Scanner(fileName);
    }catch(RuntimeException e) {
    System.err.println("Couldn't find the file");
    System.exit(0);
    //Set the size of the maze
    while(input.hasNextInt())
    size = input.nextInt();
    //Set Limits on coordinates
    Coordinates.setLimits(size);
    //Set the maze[][] array equal to this size
    maze = new char[size][size];
    //Fill the Array with maze values
    for(int i = 0; i < maze.length; i++)
    for(int x = 0; x < maze.length; x++)
    if(input.hasNextLine())
    String insert = input.nextLine();
    maze[i][x] = insert.charAt(x);
    Any advice would be loved =D

    Code-tags sometimes cause wonders, I replaced # with *, as the code tags interprets # as comment, which looks odd:
    ******...*.........To your code: Did you test it step by step, to find out about what is read? You could either use a debugger (e.g., if you have an IDE) or system outs to get a clue. First thing to check would be, if the maze size is read correctly. Further, the following loops look odd:for(int i = 0; i < maze.length; i++) {
        for(int x = 0; x < maze.length; x++) {
            if (input.hasNextLine()) {
                String insert = input.nextLine();
                maze[x] = insert.charAt(x);
    }Shouldn't the nextLine test and assignment be in the outer loop? And assignment be to each maze's inner array? Like so:for(int i = 0; i < maze.length; i++) {
        if (input.hasNextLine()) {
            String insert = input.nextLine();
            for(int x = 0; x < insert.size(); x++) {
                maze[i][x] = insert.charAt(x);
    }Otherwise, only one character per line is read and storing a character actually should fail.

  • Non printable characters in a text file..

    hi,
    How to get blank lines and non-printable characters
    and remove those characters from the text file being uploaded from application server .
    thanks,
    Anil.

    Take a look at the constants in cl_abap_char_utilities. A simpler solution would be to ask for a file without such characters...

  • How are control characters handled in keyboard layouts?

    Warmup question: What exactly is the difference between an "input method" and a "keyboard layout"?
    Real question: What exactly happens when I switch keyboard layouts and enter control characters, and how can I change it?
    I'll use as an example Hebrew-QWERTY and the "a" key. That key maps to Hebrew character aleph or א. What happens when I press control-a?
    The Emacs text editor claims to receive a control-aleph, saying "^א is undefined". This is a very strange character: א with bit 26 set. It doesn't even have a Unicode codepoint.
    TextEdit normally responds to control-a by moving to the start of the line. It doesn't do so with Hebrew-QWERTY in force, hence it's not getting a control-a. I have no idea what it is getting.
    The goal, by the way, is to create a keyboard layout that does NOT change the mapping of control characters. I don't want control-a to send a useless control-aleph; I want it to send control-a as usual. But if I examine the Hebrew-QWERTY layout in (say) Ukelele, it knows nothing of control-aleph and claims to map control-a to itself as usual. Therefore something else is producing these weird control characters. Who?
    If I'm hopelessly confused, please don't hesitate to say so. I wouldn't be surprised to learn that I'm missing something simple but crucial.

    Tom Gewecke wrote:
    Regarding control characters, you might try posting a query on the Ukelele page -- the fellow who makes that app knows a lot about how all this works.
    Layout vs Method: Thanks for the clarification.
    Ukelele: I've already posted to the Ukelele-users Google group, thus:
    http://groups.google.com/group/ukelele-users/browse_thread/thread/b9c8aadfd6969c 15?hl=en
    If that's what you mean by "the Ukelele page", I'm all set (assuming he replies). If you meant somewhere else, please let me know. I didn't find an Apple discussion forum specifically for Ukelele.

  • Control Characters visible in code view

    Not sure how I managed to turn on this "feature" but when I'm looking at any .cfc file in CFBuilder I see lightly grayed out controll characters (like \n for new line or >> for tab, or ..... for spaces). Not a really big deal, but damned annoying when you're staring at it for a while. Does anyone know how to turn this off?

    I'll share that I point out that and many other little hidden gems in a talk of that name, available online:
    http://carehart.org/presentations/#cfbgems
    I realize you wouldn't have thought to look there for the answer, but I'm saying that if folks using CFB were to check it out, they may learn lots of other little surprises (solutions/features) like that. Hope it helps someone.
    /charlie

  • Scanning characters in a text file

    Hello, firstly I am trying to get the program to work, then I will use different methods (program description shown in code).
    I have not done Java for a while therefore I do not know if i am on the right track or not - please say. Basicly I have the characters in an array, but when I display them its looks like 160, 160, 12, 13, etc etc i.e. their is a separate number for each character.
    What I need to know is how to I get this number back to a character?
    Thank you anyone
    import java.io.*;
    * Write an application which scans through a text file, and counts
    * (and displays) the occurrences of a particular character (supplied
    * by the user) on each line of the file. Use a method to count the
    * occurrences on one line. The specification of the method should be:
    * private int countCharacters(String line, char c)
    * The method returns the number of �c� character in the line.
    public class TextfileScan2
         public static void main(String[] args)throws Exception
              byte[] byteArray = new byte[100];
              FileInputStream in = new FileInputStream("File.txt");
              int byteRead;
              int index = 0;
              while ((byteRead = in.read()) != -1)
                   byteArray[index] = (byte)byteRead;
                   index++;
              in.close();
              for(int i = 0; i < byteArray.length; i++)
                   System.out.println(byteArray);

    No need to get quite so uptight. Anyway I think I am making progress although what I have does not compile as it says I need to add curly braces to lines 28 and 44.
    Can someone please tell me why I get this error. Maybe the name of the methods - have tried changing but no luck.
    cheers
    import java.io.*;
    * Write an application which scans through a text file, and counts
    * (and displays) the occurrences of a particular character (supplied
    * by the user) on each line of the file. Use a method to count the
    * occurrences on one line. The specification of the method should be:
    * private int countCharacters(String line, char c)
    * The method returns the number of �c� characters in the line.
    public class TextfileScan2
         public int main(String[] args)throws Exception
              BufferedReader in = new BufferedReader(new FileReader("File.txt"));
              String line = null;
              String lines = null;
              while((line = in.readLine()) != null)
                   lines = line;
              countCharacters(line);
         private int countCharacters(String line)
              char[] charArray = line.toCharArray();
              int c = 0;
              for(int i = 0; i < charArray.length; i++)
                   if(charArray[i] == 'c')
                        c++;
              System.out.print("There are " + c + " 'c' characters in line");
    }

  • How to read characters from a text file in java program ?

    Sir,
    I have to read the characters m to z listed in a text file .
    I must compare the character read from the file.
    And if any of the characters between m to z is matched i have to replace it with a hexadecimal value.
    Any help or suggesstions in this regard would be very useful.
    Thanking you,
    khurram

    Hai,
    The requirement is like this
    There is an input file, the contents of the file are as follows, you can assume any name for the file.
    #Character mappings for Japanese Shift-JIS character set
    #ASCII character Mapped Shift-JIS character
    m 227,128,133 #Half width katakana letter small m
    n 227,128,134 #Half width katakana letter small n
    o 227,129,129
    p 227,129,130
    q 227,129,131
    r 227,129,132
    s 227,129,133
    t 227,129,134
    u 227,129,135
    v 227,129,136
    w 227,129,137
    x 227,129,138
    y 227,129,139
    z 227,129,142
    The contents of the above file are to be read as input.
    On encountering any character between m to z, i have to do a replacement with a hexadecimal code point value for the multibyte representation in the second column in the input file.
    I have the code to get the unicode codepoint value from the multibyte representation, but not from a file.
    So if you could please tell me how to get the characters in the second column, it would be very useful for me.
    The character # is used to represent the beginning of a comment in the input file.
    And comment lines are to be ignored while reading the file.
    Say i have a string str="message";
    then i should replace the m with the unicode code point value.
    Thanking you,
    khurram

  • Why are desktop icon positions for some files forgotten on restart

    On restart/reboot some of the file icon positions are forgotten and the files reappear stacked over the startup drive icon.  The remainder of the files on the desktop are in their correct/previous positions.  Why are somefile locations not remembered?

    Sounds like the .DS_Store invisible file is corrupt.  That is my wild guess.  There is a .DS_Store invisible file for each folder that the Finder visits.  It is where the Finder stores this position information.
    NOTE:  The following suggestions will cause the Finder to forget the positions of everything in the target folder, but after that the Finder should be able to remember going forward.  If you have some icons in the correct positions and you do not want to forget where they were, you should take a screen shot, or create a map (with pencil and paper), or other way to memorize where they were.
    There are utilities that can toggle the Finder internal settings to display invisible files, and then reset the settings so they are again hidden (you would trash the .DS_Store of the misbehaving folder while it was visible, then reloaunch the Finder or reboot, but a Finder relaunch is faster).
    There are Terminal commands that can be used to just remove the .DS_Store file.
    The killall Finder is needed to relaunch the Finder.  You could also use Apple menu icon -> Force Quit... -> Finder -> Relaunch.
    If a folder does not have a .DS_Store when the Finder opens the folder, the Finder will create a new one and assigns all the icons a default position.  Then you should be able to reposition the icons as you desire, and it should remember them from that point forward.

  • Need a line feed after 120 characters in a text file

    Hi ,
    I am in the verge of developing a report program which generates a text file (space delimited) for a third party vendor -
    After 80 characters (name field) - I need to have space till 120th position in the record and then the cursor should navigate to the
    the next line (line feed)  in the text file-
    I used several techniques but couldn't succeed u2013 Since there is no characters after 80th position the cursor navigates to the next line or record in the text file u2013  Can anyone help on this regard?
    Thanks in advance.
    Regards
    Rajesh.

    Rajesh,
    Insteadof  differentiating the fields in the text file with SPACE use # or @ as separator and then check by defining a field with length 40 and leave it  blank.
    K.Kiran.

  • Pictures - why are some pictures visible and some not?

    Why is it that some of the pics I transfered from my digital camera to my Macbook, iPad, from windows-system or from external drives and vs. are not visible on my Macbook.
    In this case my Macbook opens iPhoto and a while later indicates, that I will not be able to make the picture visible (cant remember the exact phrase that appears on my screen - its something like incompatibility of pics).
    Anyone, facing a similar situation, and please how to solve this fast?

    I am also having this issue, only difference is the playlist use to be on my iPhone but is not there now.  The playlist shows with no music in it now.  This particular playlist I downloaded all songs to my phone

  • Why are some of my iMessage text messages being received sporadically by my father

    I've searched high and low, but couldn't find any information regarding this particular issue, so if you know of a link in the discussions please show me.  Today my father received 2 texts from 2 seperate numbers by friends of mine.  This is troubling, and isn't the first time.  I am using an iPhone 4 fully updated to 7.0.4. I recently noticed that I was no longer sending messages as an iMessage (blue text color) so I investigated the issue within the settings function and didn't really see any differences there with the exception of the Apple ID.  I've always used my father's Apple ID and only once has this happened, the only difference was that I was receiving his messages from people in his contacts.  It is also important to mention that my carrier is Verizon and that we are on a family shared account with 4 members.  I don't think that any of the other members have ever received any of my texts, but then again I don't know if they are using just one Apple ID (I think they have there own personal IDs).  So it comes to this, do I need my own personal Apple ID?  If that is the case why do they offer the option of selecting what numbers or email addresses to choose to have my texts sent to?  Also in order for me to open an Apple ID I must be the owner of a credit card which I do not use nor do I have, not even a debit/credit card.  Anyway, that's it.  I don't need my personal life spilled into my father's life, we all have enough problems of our own!   Ciao and thanks for any and all help. 

    Mac GigaBytes wrote:
    Anyway, I followed the steps you provided, and changed all of the settings including <-- Settings <-- FaceTime and Settings <-- Messages <-- Use your Apple ID for messages.
    Just to be clear, while you have to use an Apple ID for iMessage and FaceTime, you should not be using that e-mail address to receive at or send from since you're using your father's ID.  Later in your post it sounds like you de-selected e-mail addresses that were not yours, which is correct, but I wanted to make sure you understand that you should not be using this ID for a contact point since it is not yours.
    If your father is still getting your text messages from your friends, I suspect that either:
    (a) after making these changes you need to turn iMessage and FaceTime off for a brief period, then turn back on, or
    (b) your friends are replying to older messages that you sent from your father's Apple ID, or
    (c) your father's iPhone somehow has your e-mail entered as one of the possible contact points for his iPhone.
    If the cause is (a) turn iMessage and FaceTime back on since you've already turned them off.
    If the cause is (b) see the last paragraph of my 1st post.  Send your friends a new iMessage and tell them to only reply to that conversation and delete prior conversations.
    If the cause is (b) have your father de-select (or remove) your e-mail address from his iMessage and FaceTime settings.

  • Why are there weird boxes around text in the Apple apps I use in mavericks?

    After I updated to Mavericks I noticed these weird grey boxes that appear around the text in some of the Apple-made apps I use lime Pages, Reminders, etc. Also, in a finder window, whenever some of my tabs are open, the tab's colour is different from that of the header of the window. I checked other people macs which has mavericks but none of them had the same problem. Here are a few images of my problems:

    So nobody else has seen this problem? Is that the gist I'm getting?

Maybe you are looking for

  • My screen freeze daily from nokia Lumia 920

    The last days my screen freeze and then I always need put back the time

  • Posting of Loan - Payment and recovery from Employees

    Dear All, We have done the configuration for Loans. Its working fine. Now we want to post the amount to FI to the concerned Employees Account to track the payment and recovery.. How do we do this... What are the steps, process, configurations?? Pls l

  • Very frequent BSODs on Windows Vista Ultimate

    Hi everyone. I am a happy owner of an Aluminium MacBook, but, unfortunately, not when it comes to Windows. The system crashes pretty much every time I go on it. It happens upon various tasks - launching a game, watching IPTV (which is the main reason

  • Att: NLSurfMan

    Still remember u code a file called "Explorer.jsp"(<-- file manager)?????? i follwed ur codes but there are errors which i cannot solved.Can u help me to solve? <html> <head> </head> <body> <style> P,BODY,TD font-family: courier new; </style> <pre> <

  • Error "User Expiry Date Overlaps" while login into system

    Dear Consultants, A strange problem started occurring in our System.When we are trying to login in SAP system from any user apart from SAP*, after giving user name and password it gives error:- "user expiry date overlaps". I want to mention here our