Discussion:
[Ubuntu-PH] help on script
cj pangilinan
2011-07-15 18:28:51 UTC
Permalink
Hi List,

I need help on writing a script or a one-liner command in Unix.

Create a script to find all project.xml file under the current directory and
open it and replace "file:C:/folder/file.txt" with "file:/work/dir/file.txt"
and then close it.

Thanks in advance.
--
Carlos Jhunie L. Pangilinan, Jr.

:::::::::::::::::::::::::::::::::::::::::::::
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-ph/attachments/20110715/17f89efd/attachment.html>
Ian Dexter R. Marquez
2011-07-16 02:34:38 UTC
Permalink
Post by cj pangilinan
Create a script to find all project.xml file under the current directory and
open it and replace "file:C:/folder/file.txt" with "file:/work/dir/file.txt"
and then close it.
What have you done so far?
--
Ian Dexter R. Marquez
http://iandexter.com
cj pangilinan
2011-07-16 13:21:52 UTC
Permalink
find . -name project.xml -type f |xargs perl -pi -e 's/string1/string2/g'

but I can't seem to work -name project-*.xml. How do I replace project.xml
with multiple files like project-*.xml

--
Carlos Jhunie L. Pangilinan, Jr.
Post by cj pangilinan
Post by cj pangilinan
Create a script to find all project.xml file under the current directory
and
Post by cj pangilinan
open it and replace "file:C:/folder/file.txt" with
"file:/work/dir/file.txt"
Post by cj pangilinan
and then close it.
What have you done so far?
--
Ian Dexter R. Marquez
http://iandexter.com
--
ubuntu-ph mailing list
ubuntu-ph at lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-ph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-ph/attachments/20110716/463ec372/attachment.html>
Ian Dexter R. Marquez
2011-07-16 13:44:06 UTC
Permalink
Post by cj pangilinan
find . -name project.xml -type f |xargs perl -pi -e 's/string1/string2/g'
but I can't seem to work -name project-*.xml. How do I replace project.xml
with multiple files like project-*.xml
Have you tried enclosing the pattern in quotes?

man find:

"Don't forget to enclose the pattern in quotes in order to protect it
from expansion by the shell."
Post by cj pangilinan
On Sat, Jul 16, 2011 at 10:34, Ian Dexter R. Marquez <iandexter at gmail.com>
Post by Ian Dexter R. Marquez
Post by cj pangilinan
Create a script to find all project.xml file under the current directory and
open it and replace "file:C:/folder/file.txt" with
"file:/work/dir/file.txt"
and then close it.
What have you done so far?
--
Ian Dexter R. Marquez
http://iandexter.com
cj pangilinan
2011-07-17 07:42:32 UTC
Permalink
Wow great. That's it. I missed that. It now works. Thanks.

--
Carlos Jhunie L. Pangilinan, Jr.
Post by cj pangilinan
Post by cj pangilinan
find . -name project.xml -type f |xargs perl -pi -e 's/string1/string2/g'
but I can't seem to work -name project-*.xml. How do I replace
project.xml
Post by cj pangilinan
with multiple files like project-*.xml
Have you tried enclosing the pattern in quotes?
"Don't forget to enclose the pattern in quotes in order to protect it
from expansion by the shell."
Post by cj pangilinan
On Sat, Jul 16, 2011 at 10:34, Ian Dexter R. Marquez <
iandexter at gmail.com>
Post by cj pangilinan
Post by Ian Dexter R. Marquez
Post by cj pangilinan
Create a script to find all project.xml file under the current
directory
Post by cj pangilinan
Post by Ian Dexter R. Marquez
Post by cj pangilinan
and
open it and replace "file:C:/folder/file.txt" with
"file:/work/dir/file.txt"
and then close it.
What have you done so far?
--
Ian Dexter R. Marquez
http://iandexter.com
--
ubuntu-ph mailing list
ubuntu-ph at lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-ph
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-ph/attachments/20110717/cef5ed99/attachment.html>
hard wyrd
2011-07-16 02:44:42 UTC
Permalink
find . -type f -print0 | xargs -0 sed -i 's/string1/string2/g'
Post by cj pangilinan
Hi List,
I need help on writing a script or a one-liner command in Unix.
Create a script to find all project.xml file under the current directory
and open it and replace "file:C:/folder/file.txt" with
"file:/work/dir/file.txt" and then close it.
Thanks in advance.
--
Carlos Jhunie L. Pangilinan, Jr.
--
ubuntu-ph mailing list
ubuntu-ph at lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-ph
--
-------------------------------------------------------------
"Penguin, penguin, and more penguin !"

http://www.webhostadmins.com
http://www.madforubuntu.com
http://baudizm.blogsome.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-ph/attachments/20110716/5ba048ad/attachment.html>
Loading...