1

I'm trying to run a grep command on remote system to give me the result for May 22. But reply comes

/bin/grep: /var/log/Clients_Logs/127.0.0.1/*: No such file or directory

But when I specifically provide the filename, it works and gives me the results.

This command gives me an error

ssh -tt emerg@xxx.xxx.xxx.xxx  'sudo /bin/grep -r "May 22" /var/log/Clients_Logs/127.0.0.1/*'
2
  • Problem : * is not getting expanded and there really is no such file named * ; Solution : try removing the last * and it will work. – Prem May 22 '16 at 10:00
  • Yes @Prem you are right , it did work thanks. Please put it answer section so i can commit it – OmiPenguin May 22 '16 at 10:05
3

Problem : * is not getting expanded ; there really is no such file named * , so grep reports that.

Solution : remove the last * ; it will work with -r , making grep look into all the files in that Directory.

2
  • 1
    And the cause, I'm guessing, is that the directory is only accessible by root, therefore the shell doesn't have enough permissions to expand * there (since this happens before sudo). – user1686 May 22 '16 at 14:43
  • Correct , @grawity ; At the very least , that Directory may not be accessible by user "emerg" , who is executing the sudo. – Prem May 22 '16 at 15:00

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.