Skip to main content
added 15 characters in body
Source Link

I am attempting to find files and then grep expression for some string in the files, then only get back the full directory path the files are found in.

find `pwd` -iname '*.py' -type f -exec bash -c "grep -l 'nn'; sed 's[\/](.*)*[\/]/d' {}" \; 

However, the sed expression will have the terminal hang, rather than recursively print out the files and removing the file from the directory path.

I know I can partially achieve this with:

find `pwd` -iname 'nn*' -type d 

However, I wanted to knowthis expects the correctdirectory name to have grep+sednn argumentsand not for future casesnn inside the file.

I am attempting to find files and then grep expression for some string in the files, then only get back the full directory path the files are found in.

find `pwd` -iname '*.py' -type f -exec bash -c "grep -l 'nn'; sed 's[\/](.*)*[\/]/d' {}" \; 

However, the sed expression will have the terminal hang, rather than recursively print out the files and removing the file from the directory path.

I know I can achieve this with:

find `pwd` -iname 'nn*' -type d 

However, I wanted to know the correct grep+sed arguments for future cases.

I am attempting to find files and then grep expression for some string in the files, then only get back the full directory path the files are found in.

find `pwd` -iname '*.py' -type f -exec bash -c "grep -l 'nn'; sed 's[\/](.*)*[\/]/d' {}" \; 

However, the sed expression will have the terminal hang, rather than recursively print out the files and removing the file from the directory path.

I can partially achieve this with:

find `pwd` -iname 'nn*' -type d 

However, this expects the directory name to have nn and not for nn inside the file.

added 156 characters in body
Source Link

I am attempting to find files and then grep expression for some string in the files, then only get back the full directory path the files are found in.

find `pwd` -iname '*.py' -type f -exec bash -c "grep -l 'nn'; sed 's[\/](.*)*[\/]/d' {}" \; 

However, the sed expression will have the terminal hang, rather than recursively print out the files and removing the file from the directory path.

I know I can achieve this with:

find `pwd` -iname 'nn*' -type d 

However, I wanted to know the correct grep+sed arguments for future cases.

I am attempting to find files and then grep expression for some string in the files, then only get back the full directory path the files are found in.

find `pwd` -iname '*.py' -type f -exec bash -c "grep -l 'nn'; sed 's[\/](.*)*[\/]/d' {}" \; 

However, the sed expression will have the terminal hang, rather than recursively print out the files and removing the file from the directory path.

I am attempting to find files and then grep expression for some string in the files, then only get back the full directory path the files are found in.

find `pwd` -iname '*.py' -type f -exec bash -c "grep -l 'nn'; sed 's[\/](.*)*[\/]/d' {}" \; 

However, the sed expression will have the terminal hang, rather than recursively print out the files and removing the file from the directory path.

I know I can achieve this with:

find `pwd` -iname 'nn*' -type d 

However, I wanted to know the correct grep+sed arguments for future cases.

edited tags
Link
Kusalananda
  • 356.1k
  • 42
  • 737
  • 1.1k
Source Link
Loading