Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
07-23-2010, 01:24 PM
|
#1
|
|
LQ Newbie
Registered: Mar 2009
Posts: 6
Rep:
|
CLI Issues -- Annoying File name: \033[A\033[B\b\b , delete how?
First, please no giggling at seeing some Fortran source code. I would much rather be writing in python or some more modern language. Not my choice.
My issue is, however, that during the course of some Fortran execution, a file was created with some non-printable characters and some escape sequences. How do I delete this file? Here is a copy of my 'ls -l' output:
Code:
total 116
-rw-r--r-- 1 ##### users 7027 2010-07-08 07:10 \033[A\033[B\b\b
-rw-r--r-- 1 ##### users 0 2010-07-23 18:07 lsdump
-rw-r--r-- 1 ##### users 148 2010-07-01 20:10 makefile
drwxr-xr-x 2 ##### users 4096 2010-07-22 00:35 map/
drwxr-xr-x 2 ##### users 4096 2010-07-11 19:18 map2/
drwxr-xr-x 2 ##### users 4096 2010-07-13 23:54 map3/
drwxr-xr-x 2 ##### users 4096 2010-07-14 22:59 map4/
drwxr-xr-x 2 ##### users 4096 2010-07-15 06:53 map5/
-rwxr-xr-x 1 ##### users 14687 2010-07-22 00:34 psmod.f90*
-rw-r--r-- 1 ##### users 8347 2010-07-09 04:47 psmod.mod
-rw-r--r-- 1 ##### users 20920 2010-07-09 20:06 psmod.o
-rwxr-xr-x 1 ##### users 1988 2010-07-09 20:22 pstest.f90*
-rwxr-xr-x 1 ##### users 26521 2010-07-09 20:06 pstest.out*
The culprit file is \033[A\033[B\b\b.
The relevant commands attempted so far are:
$ rm \033[A\033[B\b\b
rm: cannot remove `033[A033[Bbb': no such file or directory
$ rm '\033[A\033[B\b\b'
rm: cannot remove `\\033[A\\033[B\\b\\b': no such file or directory
What gives? Is there another way to reference a file without the file name?
Shell is Bash on a Slackware machine.
|
|
|
|
07-23-2010, 01:40 PM
|
#2
|
|
Member
Registered: May 2007
Distribution: Ubuntu 10.04
Posts: 58
Rep:
|
Hopefully this will work:
ls -b
This will list all the files in the current directory replacing unprintable characters by octal characters.
Then type
rm ?
Replace ? with the exact output of the ls command above.
|
|
|
|
07-23-2010, 01:48 PM
|
#3
|
|
LQ Veteran
Registered: Sep 2003
Location: the Netherlands
Distribution: lfs, debian, rhel
Posts: 8,692
|
Hi,
This might work:
Type rm \\0 and press the tab key. If all goes well the whole filename is expanded (including the needed escapes). Pressing enter would remove the file.
Hope this helps.
|
|
|
|
07-23-2010, 03:45 PM
|
#4
|
|
LQ Newbie
Registered: Mar 2009
Posts: 6
Original Poster
Rep:
|
A.
Quote:
|
Originally Posted by rdgreenlaw
ls -b
This will list all the files in the current directory replacing unprintable characters by octal characters.
|
Output of ls -b:
Code:
$ls -b
\033[A\033[B\b\b
lsdump
makefile
map
map2
map3
map4
map5
psmod.f90
psmod.mod
psmod.o
pstest.f90
pstest.out
Unfortunately I don't see any new information present.
B.
Quote:
|
Originally Posted by druuna
Type rm \\0 and press the tab key.
|
Also unfortunately, auto-complete does not work.
$ rm \\0 [TAB] does nothing.
Thanks for the stab at my problem.
|
|
|
|
07-23-2010, 03:57 PM
|
#5
|
|
Moderator
Registered: Dec 2009
Location: Hanover, Germany
Distribution: Slackware
Posts: 12,146
|
Try it with:
Code:
rm \\033[A\\033[B\\b\\b
I tried to generate a file with the given name with
Code:
touch \\033[A\\033[B\\b\\b
and to delete it with the command above, both worked.
|
|
|
|
07-23-2010, 04:04 PM
|
#6
|
|
LQ Veteran
Registered: Sep 2003
Location: the Netherlands
Distribution: lfs, debian, rhel
Posts: 8,692
|
Hi,
Ok, try using the file inode number to remove it.
First find the inode number of this file: ls -il
The inode number is in the first column.
Code:
$ ls -li
total 0
2080802 -rw-r----- 1 druuna internet 0 Jul 23 23:02 foobar
The blue part in the previous example.
Then remove it (replace InodeNumber with the found number) : find . -inum InodeNumber -exec rm -i {} \;
Hope this helps.
Last edited by druuna; 07-23-2010 at 04:08 PM.
Reason: Added -i option for safe execution.
|
|
|
1 members found this post helpful.
|
07-23-2010, 04:37 PM
|
#7
|
|
Guru
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594
|
Code:
sasha@reactor: touch $(printf '\033[A\033[B\b\b')
sasha@reactor: ls
\033[A\033[B\b\b
sasha@reactor: rm $(printf '\033[A\033[B\b\b')
sasha@reactor: ls
sasha@reactor:

Last edited by GrapefruiTgirl; 07-24-2010 at 06:09 AM.
Reason: removed extra junk which confused the post.
|
|
|
|
07-23-2010, 07:43 PM
|
#8
|
|
Senior Member
Registered: Aug 2006
Posts: 2,695
|
Code:
# ls -ltrb
total 0
-rw-r--r-- 1 root root 0 2010-07-23 08:46 \033[A\033[B\b\b
-rw-r--r-- 1 root root 0 2010-07-23 08:46 file33.txt
$ rm -f "$(ls -1rt | grep -E "[[:cntrl:]]")"
$ ls -ltrb
total 0
-rw-r--r-- 1 root root 0 2010-07-23 08:46 file33.txt
|
|
|
|
07-23-2010, 08:21 PM
|
#9
|
|
Member
Registered: May 2007
Distribution: Ubuntu 10.04
Posts: 58
Rep:
|
I had not thought of using grep to extract the filename based on the fact that it contained one or more control characters.
This is a very good solution by ghostdog74. Hope it works for you!
|
|
|
|
07-24-2010, 02:48 AM
|
#10
|
|
Senior Member
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Slackware 10.1/10.2/12, Ubuntu 12.04, Crunchbang Statler
Posts: 3,780
|
If everything else fails, try rm -i * . It will prompt you for confirmation; make sure you only confirm what you want to delete.
|
|
|
1 members found this post helpful.
|
07-25-2010, 04:09 PM
|
#11
|
|
LQ Newbie
Registered: Mar 2009
Posts: 6
Original Poster
Rep:
|
Thank you druuna, GrapefruiTgirl, and ghostdog74 for your advice: all three methods worked in my case only after a bit of tweaking:
Code:
$ls -li
total 0
284789 -rw-r--r-- 1 corey users 0 2010-07-25 21:07 \033[A\033[B\b\b
284790 -rw-r--r-- 1 corey users 0 2010-07-25 21:04 file.txt
284798 -rw-r--r-- 1 corey users 0 2010-07-25 21:08 lsdump
$ rm $(find ./ -inum 284789)
$ ls -li
284790 -rw-r--r-- 1 corey users 0 2010-07-25 21:04 file.txt
284798 -rw-r--r-- 1 corey users 0 2010-07-25 21:08 lsdump
$
Code:
$ls -li
total 0
284789 -rw-r--r-- 1 corey users 0 2010-07-25 21:07 \033[A\033[B\b\b
284790 -rw-r--r-- 1 corey users 0 2010-07-25 21:04 file.txt
284798 -rw-r--r-- 1 corey users 0 2010-07-25 21:08 lsdump
$ rm $(printf '\033[A\033[B\b\b')
$ ls -li
284790 -rw-r--r-- 1 corey users 0 2010-07-25 21:04 file.txt
284798 -rw-r--r-- 1 corey users 0 2010-07-25 21:08 lsdump
$
Code:
$ls -li
total 0
284789 -rw-r--r-- 1 corey users 0 2010-07-25 21:07 \033[A\033[B\b\b
284790 -rw-r--r-- 1 corey users 0 2010-07-25 21:04 file.txt
284798 -rw-r--r-- 1 corey users 0 2010-07-25 21:08 lsdump
$ rm $(ls | grep -E "[\[:cntrl:]]")
$ ls -li
284790 -rw-r--r-- 1 corey users 0 2010-07-25 21:04 file.txt
284798 -rw-r--r-- 1 corey users 0 2010-07-25 21:08 lsdump
$
Thanks again for all the help 
|
|
|
|
07-25-2010, 07:49 PM
|
#12
|
|
Guru
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594
|
You can now mark this [solved] using Thread Tools, at the top of the thread. 
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 04:29 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|