LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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


Reply
  Search this Thread
Old 11-27-2009, 04:22 AM   #1
MOCKBA
Member
 
Registered: Oct 2003
Location: Moscow
Distribution: Ubuntu
Posts: 61
Blog Entries: 1

Rep: Reputation: 15
Accessing file from cli having special characters in name


I have a file created by some download program and generally the file name has "unprintable characters" from Linux command line point view. The cahacters are displayed as P?P?P? and so on. Copy/paste seems not working. So question is how can I manage these files? I can't even rename them, since no way to input any characters from name. MS-DOS has a nice feature as show me 8.3 file name only printable characters, however is missed in Linux. What to do? Do not suggest to access from MS-DOS though, I need these files under Linux.
 
Old 11-27-2009, 05:19 AM   #2
H_TeXMeX_H
LQ Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301Reputation: 1301
You can do 'ls -b' to see non-printable characters, and then you can rename them.
 
Old 11-27-2009, 04:39 PM   #3
MOCKBA
Member
 
Registered: Oct 2003
Location: Moscow
Distribution: Ubuntu
Posts: 61

Original Poster
Blog Entries: 1

Rep: Reputation: 15
Thanks for tip, unfortunately it doesn't work. It uncovered only some blanks. The rest, symbols like § I even acn't copy paste to make some reg expression. Is there some 3rd party program? I guess sisnce ls shows files, it can obtain handlers and rename. So if some program has the functionality.
 
Old 11-27-2009, 08:11 PM   #4
lwasserm
Member
 
Registered: Mar 2008
Location: Baltimore Md
Distribution: ubuntu
Posts: 184

Rep: Reputation: 41
This might be an example where a gui is better than the cli. Is X and some kind of gui desktop with a file manager like nautilus or thunar running on the system? If not how about a character mode file manager like midnight commander?
mc
 
Old 11-27-2009, 09:24 PM   #5
18Googol2
Member
 
Registered: Oct 2008
Distribution: FreeBSD, RedHat, Centos, Solaris, AIX
Posts: 34

Rep: Reputation: 17
Quote:
Originally Posted by lwasserm View Post
This might be an example where a gui is better than the cli. Is X and some kind of gui desktop with a file manager like nautilus or thunar running on the system? If not how about a character mode file manager like midnight commander?
mc
So you dont know how to manage it in CLI, then you conclude the GUI is better?

OP: To rename that file:

$ \ls -ia

Take note the number next to the file name.

$ find . -maxdepth 1 -inum the_number_you_got_from_previous_command -exec mv {} new_file_name \;
 
Old 11-28-2009, 09:11 AM   #6
lwasserm
Member
 
Registered: Mar 2008
Location: Baltimore Md
Distribution: ubuntu
Posts: 184

Rep: Reputation: 41
Quote:
Originally Posted by 18Googol2 View Post
So you dont know how to manage it in CLI, then you conclude the GUI is better?
Actually, I do know how to manage it with cli, and concluded that gui is better.
 
Old 11-30-2009, 12:33 AM   #7
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Try any of these

1. use single quotes around the name
2, try escaping '\' each bad char
3. try moving all normal files out of the dir, then cd up one and try something like
Code:
for file in /bad_dir
do
    mv $file new_file
done
using the find cmd instead of '/bad_dir' may work better.
Basically use a technique that reads the dir's inode entries instead of using filenames.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
removing file with special characters rsashok Linux - General 4 02-09-2010 04:08 PM
Special characters in file names Jinouchi Linux - Newbie 7 07-25-2009 11:48 AM
How to remove file with name containing only special characters abhisheknayak Linux - Newbie 5 07-04-2008 10:53 AM
Use of special characters in .netrc file jlarsen Linux - General 3 08-01-2007 10:12 AM
Convert special characters in text file nyk Linux - Software 1 01-05-2005 03:20 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration