Accessing file from cli having special characters in name
Linux - GeneralThis 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.
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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
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?
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.