Forums
New posts
Articles
Product Reviews
Policies
FAQ
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Menu
Log in
Register
Install the app
Install
Forums
Apple Computing Products:
macOS - Operating System
how to remove the same text for many files at once
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Raz0rEdge" data-source="post: 1078469" data-attributes="member: 110816"><p>No software that I know of..but you can certainly do this from the command line with a little bit of scripting..SED comes to mind as the fastet way of doing it..</p><p></p><p>So for example..</p><p>[CODE]</p><p>for file in `ls`; do echo "Original - $file"; cat $file; cat $file | sed -e '/This is the third line/d' > .$file.tmp; echo "Changed - $file"; cat .$file.tmp; done</p><p>[/CODE]</p><p>will produce the following:</p><p></p><p></p><p></p><p>Notice that the "This is the third line" has been deleted from both the FOO and BAR files..</p><p></p><p>Now I'm just using the string wholesale..but you can get creative with the regular expressions if need be..</p><p></p><p>Once you're satisified with the changes, you'd want to do add "mv .$file.tmp $file" as the last thing before "done" so that the modified file overwrites the original file..</p><p></p><p><strong>Warning:</strong> Make a backup of your files before trying any of this!</p><p></p><p>Regards</p></blockquote><p></p>
[QUOTE="Raz0rEdge, post: 1078469, member: 110816"] No software that I know of..but you can certainly do this from the command line with a little bit of scripting..SED comes to mind as the fastet way of doing it.. So for example.. [CODE] for file in `ls`; do echo "Original - $file"; cat $file; cat $file | sed -e '/This is the third line/d' > .$file.tmp; echo "Changed - $file"; cat .$file.tmp; done [/CODE] will produce the following: Notice that the "This is the third line" has been deleted from both the FOO and BAR files.. Now I'm just using the string wholesale..but you can get creative with the regular expressions if need be.. Once you're satisified with the changes, you'd want to do add "mv .$file.tmp $file" as the last thing before "done" so that the modified file overwrites the original file.. [B]Warning:[/B] Make a backup of your files before trying any of this! Regards [/QUOTE]
Verification
Post reply
Forums
Apple Computing Products:
macOS - Operating System
how to remove the same text for many files at once
Top