Handy tool for mass-replacement?

  • Thread starter Tomás Ó hÉilidhe
  • Start date
T

Tomás Ó hÉilidhe

I have an indentifer in my program that I want to change. Does anyone
know of a handy little tool that will go thru all the files in a directory
and replace a given identifier with another? Something like:

massreplace KillTimer TimerStop

I know Microsoft Visual Studio has such a feature but I couldn't be
bothered installing it solely for that purpose.
 
W

Walter Roberson

=?iso-8859-1?q?Tom=E1s_=D3_h=C9ilidhe?= said:
I have an indentifer in my program that I want to change. Does anyone
know of a handy little tool that will go thru all the files in a directory
and replace a given identifier with another?

You can do it fairly easily in perl, but there is no way to do it
in a standard C program (because standard C does not offer any way
to examine the contents of a directory.)
 
J

jacob navia

Tomás Ó hÉilidhe said:
I have an indentifer in my program that I want to change. Does anyone
know of a handy little tool that will go thru all the files in a directory
and replace a given identifier with another? Something like:

massreplace KillTimer TimerStop

I know Microsoft Visual Studio has such a feature but I couldn't be
bothered installing it solely for that purpose.

The IDE of lcc-win does it, if you want

you type

wedit *.c

and in the editor you do search/replace, select all windows,
and check a few settings and that was it.
 
S

SM Ryan

#
# I have an indentifer in my program that I want to change. Does anyone
# know of a handy little tool that will go thru all the files in a directory
# and replace a given identifier with another? Something like:
#
# massreplace KillTimer TimerStop

It's easy to do in variety of shell/scripting/command languages.
You might ask in group specific to your operating system. For
example on Unix, you could do something like find -exec ed
(along with dozens of other scripts).
 
R

Robert Latest

Tomás Ó hÉilidhe said:
I have an indentifer in my program that I want to change. Does anyone
know of a handy little tool that will go thru all the files in a directory
and replace a given identifier with another? Something like:

massreplace KillTimer TimerStop

ls *.c *.h | xargs -L 1 sed -i 's/KillTimer/TimerStop/g'

(not tested)
I know Microsoft Visual Studio has such a feature but I couldn't be
bothered installing it solely for that purpose.

Oh. Windows. Well, the above is very 60-ish and unixy, but whenever I'm
forced to work in a Windows environment I like to have cygwin installed
which makes all those neat Unix command-line tools available.

robert
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top