Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

How can I delete all 'nohup.out' files within a directory recursively from my terminal? I'm using CentOS.

share|improve this question
    
Do you mean there are multiple files called nohup.out in subdirectories of one directory? If that's the case, try the following command: find . -name nohup.out -exec rm {} +. –  Risto Salminen Jan 14 at 11:41
1  
You mean "within a directory?" What is the problem with rm nohup.out*? –  Barun Jan 14 at 11:42
1  
Your question is somehow unclear, because there can't be more than one file with the particular name in one directory. –  Risto Salminen Jan 14 at 11:48
    
@RistoSalminen multiple nohup.out within one directory would not be good –  Timo Jan 14 at 11:48
add comment

1 Answer

up vote 6 down vote accepted

There can't be multiple files named nohup.out in a single directory, so I assume you mean that you want to remove it recursively:

find . -name nohup.out -exec rm {} +

If you are using GNU find, you can use -delete:

find . -name nohup.out -delete

In bash4+, you can also use globstar:

shopt -s globstar dotglob
rm -- **/nohup.out

Note, however, that globstar traverses symlinks when descending the directory tree, and may break if the length of the file list exceeds the limit on the size of arguments.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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