bcooperizcool
January 8th, 2012, 02:51 PM
I am having trouble with sed. It seems it is effecting the rest of my program, even after it's part is done.
my code, like such:
cp "$base/default" "$base/new"
while read programs; do
after=`grep "After: " < $base/$programs | sed 's/^After: //'`
sed "/$after/ a\
$programs" $base/new
done < "$base/programs"
PlistGenStart Settings-iPhone Preferences
while read gen; do
cat "$base/Sections_iPhone/$gen" >> "/Applications/Preferences.app/Settings-iPhone.plist"
done < $base/new
PlistGenEnd Settings-iPhone Settings Preferences
rm -rf "$base/new"
the contents of default is:
GroupCell
AirplaneMode
WiFi
Notifications
GroupCell
Sounds
Brightness
Wallpaper
GroupCell
General
AccountSettings
Phone
Safari
Messages
iPod
Photos
Store
Speakers
and the content of program is something like
Ch40s-Launcher
WinterSled
and there is a file in $base called each of the contents of "program", with the contents like
After: Store
or some other part of "default", so it finds and inserts the text after it finds it, modifying the file.
It then gets stuff from $base/Sections_iPhone which has files named as the things in "default" that contain text to be entered into a new file.
It is having troubles. Sed works exactly like it is supposed to, but it seems to cut off the second loop, with "$gen". It gets the first phew charachters, then cuts off, thus causing cat to get an error of "/Library/Stuff/Sections_iPhone/Ai : no such file or directory" or something similar.
If I remove the sed part, it works fine, but alas, I cannot remove sed, as it is needed, otherwise my code is pointless :(
Any suggestions?
Thanks!
my code, like such:
cp "$base/default" "$base/new"
while read programs; do
after=`grep "After: " < $base/$programs | sed 's/^After: //'`
sed "/$after/ a\
$programs" $base/new
done < "$base/programs"
PlistGenStart Settings-iPhone Preferences
while read gen; do
cat "$base/Sections_iPhone/$gen" >> "/Applications/Preferences.app/Settings-iPhone.plist"
done < $base/new
PlistGenEnd Settings-iPhone Settings Preferences
rm -rf "$base/new"
the contents of default is:
GroupCell
AirplaneMode
WiFi
Notifications
GroupCell
Sounds
Brightness
Wallpaper
GroupCell
General
AccountSettings
Phone
Safari
Messages
iPod
Photos
Store
Speakers
and the content of program is something like
Ch40s-Launcher
WinterSled
and there is a file in $base called each of the contents of "program", with the contents like
After: Store
or some other part of "default", so it finds and inserts the text after it finds it, modifying the file.
It then gets stuff from $base/Sections_iPhone which has files named as the things in "default" that contain text to be entered into a new file.
It is having troubles. Sed works exactly like it is supposed to, but it seems to cut off the second loop, with "$gen". It gets the first phew charachters, then cuts off, thus causing cat to get an error of "/Library/Stuff/Sections_iPhone/Ai : no such file or directory" or something similar.
If I remove the sed part, it works fine, but alas, I cannot remove sed, as it is needed, otherwise my code is pointless :(
Any suggestions?
Thanks!