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!
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I suck at writing scripts. I can admit that. I'd love a nice perl tutorial, if anybody has links to one. In the meantime...
Can somebody post a short script that will take a directory full of .jpg images, all of which have spaces in the filenames, and remove the spaces from the names? I'm trying to streamline the photo album for my daughter's website, but the camera we take the pictures always puts spaces in the filename...
I greatly appreciate whomever is feeling nice enough to help me here....
Ugh. I'm sorry, I usually try to search for this kind of stuff before I ask, and I have, but I cannot find the script from Tinkster to which you refer.
I've used "space" "filename" "script" and combinations of these (all with Tinkster as the username included in the post), and I still can't find what I'm looking for. Unless, of course, the script in the post I'm looking for is not being used simply to remove spaces from the name, but for some other reason and the space removal is just a side-effect or sub-feature of the script in question, in which case I'm not realizing it by reading through them.
Don't suppose you know where this post is...do you?
if [ -n "$1" ]
if [ -d "$1" ]
echo invalid directory
for i in *
NEWNAME=`echo "$i" | tr ' ' '_' | tr A-Z a-z | sed s/_-_/-/g`
if [ "$NEWNAME" != "$OLDNAME" ]
mv -v -- "$OLDNAME" "$TMPNAME"
mv -v -- "$TMPNAME" "$NEWNAME"
if [ -d "$NEWNAME" ]
echo Recursing lowercase for directory "$NEWNAME"
primarily this is for converting upper to lower case, but also does other handy formatting like replacing white space with underscores. it's also nicely recursive.
I wonder if the original script didn't copy over correctly. I like to use the code tags to help prevent that sort of problem. Also, you do know the script has to be executable in order to use ./scriptname . Otherwise, you would use sh scriptname.
Anywho, here is another sample which you would make executable and run like this ...
Note: when it looks ok, remove the echo from the move statement....
echo mv "$dir/$i" "$dir/$j"
to look like this....
mv "$dir/$i" "$dir/$j"
echo "Usage: $0 [directory]"
test -d "$1" || usage
ls $dir | grep -e "[:alnum:]" | \
while read i; do
j=`echo -n "$i" | sed -e 's/ /_/'`
echo mv "$dir/$i" "$dir/$j"
Thanks for another example. I don't know what's different about my machine that's dissallowing this.
Could I be mising a package of some sort? Besides bash, is there some language I don't have that I need? I thought I had installed just about all of it, I did the "custom" install and checked all the development tools and whatnot.
Well, I'll tinker around for awhile and see if I can get past this stupid "bad interpreter: No such file of directory" crap.
Let me know if any body has any ideas why none of these work...I'll try anything...once...