How to direct standard output from find command
Hello everyone,
I'm trying to pull out sections from a bunch of files. For one file, I use: Code:
sed '/string1/,/string2/ !d' <filename.ext >newfilename.ext Code:
find . -type f -name '*.ext' -exec sed '/string1/,/string2/ !d' {} >./NewDirectory/{}\; Thank you for your help! |
I've found the simplest approach is to put your complex command inside an executable script file, and use pass it the filename as a parameter.
Code:
echo "sed '/string1/,/string2/ !d' <${1} >NewDirectory/${1}" > sedscript.sh |
I don't think that it will work in this way. The problem is that the shell concludes that the command has ended when it sees the redirection operator (>), so the filename here is no longer within the scope of the find command.
Have you tried this instead?: Code:
for file in `find . -type f`; do |
Thank you Ian and Robhogg for your helpful replies. I ended up using a shell script as suggested.
|
All times are GMT -5. The time now is 12:25 AM. |