0
find /media/shamsad/1E8A00A88A007E91/ -name '*.json' \
    -exec  mongoimport --db twitter --collection twitterCol --file {} \;

The above script was working perfectly but the below one is generating an error:

find /Desktop/L3T1/DatabaseSessional/TestMongotweet/ -name '*.json' \
    -exec  mongoimport --db twittersmall --collection twitterdata --drop --file {} \;

Error:

find: ‘/Desktop/L3T1/DatabaseSessional/TestMongotweet/’: No such file or directory

Is there a whitespace problem?

7
  • 3
    Did you really mean /Desktop? or should that be ~/Desktop? May 6, 2017 at 11:44
  • It's in my Desktop. So I need to put a '~' sign before Desktop?
    – sphoenix
    May 6, 2017 at 11:45
  • 1
    @sphoenix Yes you need to add ~. Some additional details about it: askubuntu.com/questions/516702/…
    – edwinksl
    May 6, 2017 at 11:51
  • But why it's working for the first one?
    – sphoenix
    May 6, 2017 at 11:55
  • 1
    /media is in the root directory. (assuming that your user name is "bob") your desktop directory will probably be /home/bob/Desktop... , The "~" is a shortcut for /home/bob May 6, 2017 at 12:02

1 Answer 1

3

Your Desktop directory is stored in your home directory, and your home directory is normally a subdirectory of /home with the same name as your login. So if your user name was "bob" your desktop directory will probably be /home/bob/Desktop (note that when the account is created, /home/user_name is just the default -- it could be set to something else). You can use ~ as a shortcut for typing the path to your home directory.

Therefore if you want to search you Desktop directory, you should refer to it as ~/Desktop and your command would become

find ~/Desktop/L3T1/DatabaseSessional/TestMongotweet/ -name '*.json' \
-exec  mongoimport --db twittersmall --collection twitterdata --drop --file {} \;

/media, the place the system typically mounts CDROMs, USB sticks etc., is in the root directory and therefore your first command worked fine.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .