AIX 5  How to delete a folder "abc^M"

Posted on 2007-10-06
Last Modified: 2013-12-20

Recently, I used a self custom script to extract a list of file into a folder.  Unluckily, the script is encoded in wrong because of the ascii / binary problem.  All the line ended with ^M and therefore extract it into a new folder.  e.g  "extract -xvf xxx.sar -R /abc^M"

By using ls -l, there are two folders with the same name:-
drwxr-xr-x     8     suppt    system   4096   Sep 15    23:50 abc
drwxr-xr-x     6     root       system  3584   Sep 15     23:51 abc
drwxr-xr-x     8     suppt    system   4096   Sep 15    23:50 abc.bak
drwxr-xr-x    11    suppt    system   2048   Jun 17      10:45  global

By using ls -l, like this
abc         abc.bak

I wanna to delete the second line folder
"root       system  3584   Sep 15     23:51 abc"  
Any solutions?

Please advice.  Thanks in advance.
Question by:towo2002
    LVL 40

    Accepted Solution


    What is the last char is it cntl-M or hatM (hat == ^)?

    Any way, if you are referring to a hidden char, then try:

    rm -ri abc?

    the "?" refer to single char in the dir name. The -i is to make it interactive (to confirm before it deletes the file).

    LVL 1

    Author Comment

    Thanks omarfarid

    It works.  Great!!!

    How about if there are 2 hidden char, I've to use 2 "??" then?

    Please advice, thanks.
    LVL 40

    Expert Comment

    Yes, ?? will do
    LVL 1

    Author Comment

    Great, thanks!!!
    LVL 48

    Expert Comment

    Also useful to know is the -b option to ls.

    If you do

    ls -lb

    it will display any unprintable characters in filenames.  This is particularly useful if a filename contains a bunch of control characters.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
    Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
    Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
    In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now