Find the answer to your Linux question:
Results 1 to 5 of 5
So I will be copying a whole load of files onto my (newly) linux box (suse 10), but I just realized that linux is like dos in its dislike of ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2006
    Posts
    9

    Basic file name questions...plus more!


    So I will be copying a whole load of files onto my (newly) linux box (suse 10), but I just realized that linux is like dos in its dislike of spaces and long file names, correct? what happens when i drag my windows and mac files, chock full of spaces and 60 characters long, onto the linux network drives? I wish I could just let them keep their names, some have important information about when the files (mostly photos) were created, where, for what client etc. that help me search for them if I need them quickly.

    If this is not possible, which I must assume it is not, is there a simple way to add _s instead of spaces? what about very long file names?

    Also, what about backing up program files etc. which have spaces in their names? Obviously I'm just worried that if I needed to copy them back to my windows or mac machines that they would be all full of _'s and useless.

    Finally (the "plus more" section), on relatively random other linux notes, does anyone know if it's possible to 'search' through a shared linux drive via mac's spotlight or perhaps the google desktop search?

    and lastly, i was thinking (hoping to) run my noisy "server" headless and control it from my desk via an old, old laptop via the suse remote desktop (or whatever it's called)...however, the laptop has a 2gig HD and only 32mb of ram. Not worth upgrading the old craptop, i just thought it would make a quiet, small and handy "remote monitor and keyboard" of sorts. suse states its hardware requirements at 128mb ram and 500mb HD space for minimal install, 3.5gigs for full...would a swap file of 200mb or something make it possible to run suse? and would the remote desktop program be cut if i only have 1.8gigs of HD for the install?

    Dern, I ask a lot of questions. Thanks for the help, it sure is easier to get answers for linux questions than windows despite that whole ratio thing.

  2. #2
    Super Moderator Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,934
    Firstly, Linux has no problem with spaces in filenames. All you need to remember is that when you type one in, either enclose the whole filename in quotes, e.g.:

    Code:
    "this file.txt"
    or preceed the space with a backslash, e.g.:

    Code:
    this\ file.txt
    I have no experience of Mac spotlight, maybe you could run searches using the Linux tools? Take a look at the man pages for 'find' and 'grep'.

    You can run your machine headless. If you find your machine isn't up to suse, then you can always investigate one of the smaller distros such as DSL. For remote desktop use, run with no graphical logon, but use VNCServer as a service instead, then you can connect from any machine (but dont forget to set your password).
    Linux user #126863 - see http://linuxcounter.net/

  3. #3
    Just Joined!
    Join Date
    Jan 2006
    Posts
    9
    aaaah, I see, I always had trouble wish spaces in DOS, despite quotes, but I'm glad to hear linux isn't so picky.

    I think you're right, DSL sounds like a perfect match for the old craptop, and something like tightVNC apparently allows KDE to be run, perfect. what about file name length? It doesn't look like it's going ot be a problem, but is its default shorter than windows 2000/XP? and if so, can it be changed?

  4. $spacer_open
    $spacer_close
  5. #4
    Linux User oosterhouse's Avatar
    Join Date
    Jan 2006
    Location
    Grand Rapids, MI
    Posts
    318
    Linux can have up to 250 characters in the filename..don't worry.

  6. #5
    Linux User muha's Avatar
    Join Date
    Jan 2006
    Posts
    290
    if you decide to get rid of the spaces you can:
    1. rename ' ' '_' <somefile>
    where <somefile> can also be * for all files. Do this if there is *only* one space,
    arrowup and enter a couple times to get rid of them all.

    or you can
    2. for i in *; do mv "$i" `echo $i | tr ' ' '_'`; done
    If you have alot of spaces and you want to get rid of them at once.

    If you want to copy them to a new dir that is a subdir of the current one called new:
    for i in *; do cp "$i" ./new/`echo $i | tr ' ' '_'`; done
    it gives one error which is not a problem:
    cp: omitting directory `new'

    3. you can also do the renaming in a script that you can place in your own homedir/bin. (if you have one. if you don't make it and add it to your path)
    Save these five lines as remove_spaces.sh in ~/bin/
    #!/bin/sh
    # remove spaces from all filesnames in a dir
    # usage: remove_spaces.sh
    for i in *; do mv "$i" `echo $i | tr ' ' '_'`;
    done

    Than when in ~/bin/ we have to chmod the script to make it executable so:
    chmod 711 remove_spaces.sh
    You can then run it in the dir where your files with spaces are like:
    remove_spaces.sh *
    (of course you can also write a script to automate this, etc etc ...)

    adding ~/bin/ to your path:
    #################
    You can view the list of directories where your shell looks for scripts to execute (called PATH) with the following command:
    echo $PATH
    This will return a colon separated list of directories that will be searched if a specific path name is not given when a command is attempted.
    You can add directories to your path with the following command, where directory is the name of the directory you want to add:
    export PATH=$PATH:directory
    For me ~/bin was already added.
    A better way would be to edit your .bash_profile file to include the above command. That way, it would be done automatically every time you log in.

    happy renaming!
    Muha!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •