xargs +sed question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'd normally ask this in comp.os.linux.misc, but my news server is not
responding, so I'm asking it here.

I have a bunch of files in a directory tree in which I want to replace a
string A with string B. I'm trying to do this with xargs like so:

grep -ri -l A . | xargs sed -e 's/A/B/g'

and this does what I want, except, of course, that it outputs everything
to stdout. Is there any way to pass the name of each input file as
output for sed? 



Of course, I an do

for file in `grep -ri -l A .`
do
cat $file | sed -e 's/A/B/g' > tmp
/bin/mv tmp $file
done

but the xargs method seems more elegant if there was a way to specify
separate output files. Suggestions?

Thanks!

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux