search directory-find files-append at end of line

Hi,

I have a command "get_data" with some parameters in few *.text files of a directory. I want to first find those files that contain this command and then append the following parameter to the end of the command.

example of an entry in the file :-

get_data -x -m50 /etc/web/getid

this should be changed to

get_data -x -m50 /etc/web/getid -ADD 31 -yxm

The value -ADD 31 -yxm should be repeated to all the files that contain this command

Thanks

Try this :

$ list=$(find . -type f -exec grep -l "get_data " {} \;)
$ for i in $list
> do
> mv $i ${i}.old
> cat ${i}.old | sed 's/get_data.*/& -ADD 31 -yxm/' > $i
> done

Good luck ! :cool: