Re: Variable assigned to grep output - missing letter n!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



--On Wednesday, July 20, 2011 02:53:06 PM -0500 Sean Carolan
<scarolan@xxxxxxxxx> wrote:

> Now the next
> question would be, how can I include the \n characters in my variable
> string, without fudging with $IFS?

Can you describe, functionally and a bit higher level, what you're
trying to achieve?  Is myvar supposed to contain the entire file
content if the file contains "lorem", or just any lines containing
lorem complete with newline, or are you expecting some other form 
of delimiter, or what?  Also of interest is what you're going to do
with myvar after the fact (write it out, do a replacement, whatever).

For example, if you're trying to do some form of processing that
only considers lines containing lorem, other tools might give
a cleaner, faster, and more maintainable result:

   #! /usr/bin/perl
   use taint;
   use strict;

   while (<>) {
      if (m,lorem,) {
         # do something with $_
      }
   }

(No, I don't advocate perl for everything, but knowing more about the
problem can
help in determining a suitable solution.)

Devin
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos


[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux