Extending this question: How to Create several files from a list in a text file?
Summary:
cat file_full_of_files_names | tr ' \t' '\n\n' | while read filename; do
if test -f "$filename"; then
echo "Skipping \"$filename\", it already exists"
else
cp -i initial_content "$filename"
fi
done
works great for what I want, but I'd like to extend it. The content below is what is found in 'initial_content'
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/com_aac_cachemate_demo_cachemate" /> </selector>
I'd like to change the
@drawable/"XYZ"
XYZ variable to the name of the file created using the content from
initial_content
but with the XYZ variable filled in with the filenames from
file_full_of_file_names
content.
Any script kiddies? Bashers? Thanks for any help!
Using
AWK
instead ofcp
:Test: