8

was want to search for a specific file on my server and directly edit it within nano.

i tried it like this, but it wont work

find -name file.php | xargs nano $1

the file is found, but it wont work like that

Received SIGHUP or SIGTERM

how to do that proberly?

2 Answers 2

8

Another solution is to use backticks if you have to use other command. It's for example useful with git status:

nano `git status | grep modified | awk '{ print $2 }'`

Or, with find:

nano $(find -name file\*.php)
2
  • 2
    This IS the solution for multiple files. that's why it was posted here. Feb 11, 2016 at 9:47
  • Ah, awesome! Thanks, and sorry for replying a year after it was posted.
    – daboross
    Feb 11, 2016 at 18:42
2

i found the solution in using find intern exec function

# find -name file.php -exec nano {} \;
1
  • 1
    This one will execute separate command for each found file, so you will for example lose buffer. Feb 11, 2016 at 18:59

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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