Skip to main content
formatting the code like code and removing the closing thanks etc.
Source Link
Eric Renouf
  • 18.7k
  • 7
  • 51
  • 66

I've many files in a directories structure. I want to extract some string (namely urls) by using a regexp, from those files.

I've tried this :

find . -path "alder/ * / * .html" -print | xargs sed -n "/http://[^'"]/p" > urls.txt

find . -path "*alder/ * / * .html" -print | xargs sed -n "/http:\/\/[^'\"]*/p" > urls.txt

... but it does not work as expected. The 'find'find part works ok, the 'xargs'xargs one, ok but the 'sed'sed one, no. All I get in urls.txt is the concatenation of all files.

Tricky. I'd be grateful for any help.

MC

I've many files in a directories structure. I want to extract some string (namely urls) by using a regexp, from those files.

I've tried this :

find . -path "alder/ * / * .html" -print | xargs sed -n "/http://[^'"]/p" > urls.txt

... but it does not work as expected. The 'find' part works ok, the 'xargs' one, ok but the 'sed' one, no. All I get in urls.txt is the concatenation of all files.

Tricky. I'd be grateful for any help.

MC

I've many files in a directories structure. I want to extract some string (namely urls) by using a regexp, from those files.

I've tried this :

find . -path "*alder/ * / * .html" -print | xargs sed -n "/http:\/\/[^'\"]*/p" > urls.txt

... but it does not work as expected. The find part works ok, the xargs one, ok but the sed one, no. All I get in urls.txt is the concatenation of all files.

Source Link

How to print lines using find and sed in multiple files?

I've many files in a directories structure. I want to extract some string (namely urls) by using a regexp, from those files.

I've tried this :

find . -path "alder/ * / * .html" -print | xargs sed -n "/http://[^'"]/p" > urls.txt

... but it does not work as expected. The 'find' part works ok, the 'xargs' one, ok but the 'sed' one, no. All I get in urls.txt is the concatenation of all files.

Tricky. I'd be grateful for any help.

MC