On Sat, 17 Apr 2010, William Park wrote:
> On Fri, Apr 16, 2010 at 01:22:24AM -0700, Radim wrote:
> >
> > Hello,
> > I have such script:
> >
> > (ONLY THIS THREE LINES ARE THE COMMANDS )
> > content=$(cat $script | sed '/function codecs/,/fi;/d');
Which will fail if "$script" contains whitespace, and cat is
unnecessary:
content=$( sed '/function codecs/,/fi;/d' "$script")
> > content=$(echo $content | sed -n '/mandriva/,/fi;}/p');
> > content=$(echo $content | sed '/^\s*urpmi[:space:]--auto/p');
If you don't quote $content, echo will put it all on one line.
content=$(echo "$content" | sed -n '/mandriva/,/fi;}/p');
content=$(echo "$content" | sed '/^\s*urpmi[:space:]--auto/p');
--
Chris F.A. Johnson, <http://cfajohnson.com>
Author:
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)