I accidentally executed this command in SSH:

mv /var/www/vhosts/website/httpdocs/magento/*

Now all the data in the magento dir is gone. Does anyone know where it moved to?


  • To automagically determine in which directory your data went and if you're using Bash, do this: a=( /var/www/vhosts/website/httpdocs/magento/* ); echo "${a[${#a[@]}-1]}". If not in Bash, this should work: printf '%s\n' /var/www/vhosts/website/httpdocs/magento/* | tail -1. Otherwise, it's very likely in the last directory, alphanumericallywise. Done. – gniourf_gniourf Nov 5 '13 at 18:20

If the alphabetically last entry in this directory is a directory itself, they are there.

Suppose you have the files a, b and c and the directory d. In this case,

mv /var/www/vhosts/website/httpdocs/magento/*

expands to

mv /var/www/vhosts/website/httpdocs/magento/a /var/www/vhosts/website/httpdocs/magento/b /var/www/vhosts/website/httpdocs/magento/c /var/www/vhosts/website/httpdocs/magento/d

which is a command to move everything to d. Look there if there is anything.

If d wasn't a directory, mv should have complained about that.

| improve this answer | |
  • 1
    +1 : look underneath subdirs in the /var/www/vhosts/website/httpdocs/magento/* dir. Hint: the subdir still is in in the magento dir, so it should be easy as almost everything else should now be underneath it, hence there should only be one dir left (not counting those starting with a '.'). Enter that subdir, and "mv * ..". This could move things that were previously rightly underneath that directory, however, so you'll have to put them back. + any file that had the same name as a file of magento/* will have benn overwritten (if your "mv" is not aliased to "mv -i") – Olivier Dulac Nov 5 '13 at 18:01
  • 2
    neat trick with mv *: mkdir zzz; mv * which will move all the contents of the current directory into the directory zzz. Just make sure you don't have any files that sort lexagraphically after zzz. – user220438 Nov 5 '13 at 19:36

To extend the reply of glglgl:

The command line wildcard expansion in Unix-like operating systems is performed by the shell. In most cases with Linux it would be bash. Its man page explicitly states that the wildcard expansion will be alphabetically sorted. The same should be valid for most of Bourne-compatible shells.

| improve this answer | |
  • Probably not only most, but all. Otherwise there is a lack of compatibility. – glglgl Nov 5 '13 at 19:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.