Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's 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.
Quick question. I have been ripping cds and such and some of the tracks have questions marks in them and other "not so good in a file name" characters. Because of this, during the encoding process, instead of having a nice file name I have something like
M98765~v.ogg
Does anyone know of a way to actually run a find and have it pick up the grave (~) character?
I would like to rename these files (and directories) to something a more...how would you say....human readable :P.
In bash, the '~' character is a shortcut for your home directory. If you need a literal '~' character, then you have to escape it with a backslash: '/~'. The same goes for most other "illegal" filename characters, such as parentheses, quote marks, exclamation points, and especially spaces.
Also, don't forget tab-completion. Hitting the tab key when typing a filename will autofill whatever names it sees that match what you've already typed. It can often help when matching those oddball characters.
When using a file with illegal characters in a command, you can either use the backslash-escape as above, or enclose the whole filename in quotation marks so that bash will see the thing as single unit.
I suggest you get in the habit of keeping your filenames clean. Use underscores or hyphens instead of spaces, and leave out illegal characters as much as possible. It will save you some frustration. I also personally keep most of my filenames in lowercase letters only, since Linux is case-sensitive, but that's not strictly necessary.
Oh, and there's a nice perl rename command (it should be available if you have perl installed) that's handy for cleaning up file names. It uses the same substitution syntax as sed. I've been having fun learning how to use it recently.
rename "s/~/-/g" *
...will replace all the tildes in filenames with simple hyphens in the current directory.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.