Vlearns
asked on
find replace in file
sample.txt
PERM = 444
OWNER = root
GROUP = wheel
f - - - share/htdocs/include/ar/ma il/tagline s/taglines .xml ar/taglines.xml
f - - - share/htdocs/include/au/ma il/tagline s/taglines .xml au/taglines.xml
f - - - share/htdocs/include/b5/ma il/tagline s/taglines .xml b5/taglines.xml
f - - - share/htdocs/include/br/ma il/tagline s/taglines .xml br/taglines.xml
f - - - share/htdocs/include/ca/ma il/tagline s/taglines .xml ca/taglines.xml
f - - - share/htdocs/include/cf/ma il/tagline s/taglines .xml cf/taglines.xml
f - - - share/htdocs/include/cn/ma il/tagline s/taglines .xml cn/taglines.xml
f - - - share/htdocs/include/de/ma il/tagline s/taglines .xml de/taglines.xml
result.txt
PERM = 444
OWNER = root
GROUP = wheel
f - - - share/htdocs/include/ar/ma il/tagline s/taglines .xml ../trunk/aa/mail/taglines/ taglines.x ml
f - - - share/htdocs/include/au/ma il/tagline s/taglines .xml ../trunk/au/mail/taglines/ taglines.x ml
replace each line in the last (6th column) such that:
basically convert
aa/taglines.xml
to
../trunk/aa/mail/taglines/ taglines.x ml
basically
INTL/tagines.xml
to
../trunk/INTL/mail/tagline s/taglines .xml
in the last column....
can i do it using command line perl/awk?
PERM = 444
OWNER = root
GROUP = wheel
f - - - share/htdocs/include/ar/ma
f - - - share/htdocs/include/au/ma
f - - - share/htdocs/include/b5/ma
f - - - share/htdocs/include/br/ma
f - - - share/htdocs/include/ca/ma
f - - - share/htdocs/include/cf/ma
f - - - share/htdocs/include/cn/ma
f - - - share/htdocs/include/de/ma
result.txt
PERM = 444
OWNER = root
GROUP = wheel
f - - - share/htdocs/include/ar/ma
f - - - share/htdocs/include/au/ma
replace each line in the last (6th column) such that:
basically convert
aa/taglines.xml
to
../trunk/aa/mail/taglines/
basically
INTL/tagines.xml
to
../trunk/INTL/mail/tagline
in the last column....
can i do it using command line perl/awk?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
added a newline
perl -pe 's{\s+(\w+)/taglines.xml\s *$}{ ../trunk/$1/mail/taglines/ taglines.x ml\n}' sample.txt > results.txt
can you drop a line on how this regex works to help me understand :)
perl -pe 's{\s+(\w+)/taglines.xml\s
can you drop a line on how this regex works to help me understand :)
perl -pe 's{\s+(\w)/taglines.xml\s*