|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||
|
|||
|
Search and replace utility
Hi everybody.
Does anyone use a command line search and replace tool? For example, say I want to go through every text file in a directory and replace "devshed" with "devshedforums" I found one at one time but by accident. Now I can't find it and have been searching forever to find something! This would save me ALOT of time...
__________________
PostgreSQL -- the power of Oracle without the $15,000 pricetag. FreeBSD powers Yahoo! |
|
#2
|
|||
|
|||
|
Here's the utilities I am going to audition for the part!
glark glimpse isearch replaceit sarep |
|
#3
|
|||
|
|||
|
i use sed and the bash for this task:
Code:
for i in *; do cat "$i" | sed -e "s/devshed/devshedforums/" >/tmp/tmpfile cat /tmp/tmpfile > "$i" done
__________________
-- Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more. |
|
#4
|
|||
|
|||
|
Danke!
|
|
#5
|
||||
|
||||
|
I use perl - here's the command
perl -p -i.bak -e 's#old_string#new_string#g' /path/files -p means loop -i.bak will copy originals to .bak, use just -i for no backup if you are sure -e designates expression. awk or sed would do the trick as well.
__________________
Casuistry Agnostic |
|
#6
|
|||
|
|||
|
Thanks ultraslacker.
These commands are big timesavers! |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > BSD Help > Search and replace utility |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|