Re: mv doubt



2008-10-24, 07:51(-07), contracer11@xxxxxxxxx:

Hi:
Please, how could I use mv command but preventing mv to move
directories ?
When I issue:
mv /data/* /temp
all files (and directories) are moved. I only want move files.
[...]

If your shell is zsh:

mv /data/*(^/) /temp
if you also want to move hidden files:
mv /data/*(D^/) /temp

With other shells, you could do:

for f in /data/*; do
[ -d "$f" ] && [ ! -L "$f" ] && continue
mv "$f" /temp
done
(will not move hidden files)

Or:

find /data/. ! -name . -prune ! -type d -exec mv {} /temp \;
(will move hidden files).

Those solution will move symlinks, whether they are symlinks to
directories or any other type of file, if you don't want to move
symlinks to directories, in zsh:

mv /data/*(-^/) /temp

--
Stéphane
.



Relevant Pages

  • Re: mv doubt
    ... If your shell is zsh: ... if you also want to move hidden files: ... Those solution will move symlinks, ...
    (comp.unix.shell)
  • Re: Java problem
    ... I don't understand how a bizarre and mostly undocumented series of symlinks pointing to symlinks 'builds in' the possibility to replace things. ... Particularly since Bash is not a Bourne shell, I use as an example a shell that can be used to isolate compatibility differences to things outside the shell itself. ... a shell script could change the environment variable within itself, then morph from a Bourne script to a csh script, then change the envvar back and resume processing as a Bourne script. ... People who complain that Linux distribution differences are like the old unix war-era differences don't know what they're talking about; Ubuntu, OpenSUSE, Fedora, etc are all much more alike than they are different; the various competing Unixen of the late 80's and early 90's were more different than they were alike. ...
    (Fedora)
  • Re: XP-Home: Delay when accessing "Programs" menu
    ... Shell Small or Shell Large icons are used in the Start Menu. ... the Shell Small icon defaults to the System Small size. ... >> To display Hidden files and folders... ...
    (microsoft.public.windowsxp.customize)
  • Re: permission/hidden fortified spyware?
    ... Shell= Explorer.exe ... boot to safemode and delete the files ... Problem here is, even after 'show hidden files and folders', I still ... Boot into safe mode and show hidden files and system files, ...
    (alt.os.windows-xp)
  • Re: permission/hidden fortified spyware?
    ... Shell= Explorer.exe ... boot to safemode and delete the files ... Problem here is, even after 'show hidden files and folders', I still ... Boot into safe mode and show hidden files and system files, ...
    (alt.os.windows-xp)