Re: bash script regular expression

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

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 02/10/2012 01:17 PM, Kevin Martin wrote:
>
>
> On 02/10/2012 11:50 AM, Mikkel L. Ellertson wrote:
> >
>> On 02/10/2012 11:07 AM, Aaron Konstam wrote:
>> > On Thu, 2012-02-09 at 23:31 -0800, Alejandro Rodriguez Luna wrote:
>> >> Hi everyone, I was creating a script and i found something i can't
>> >> figure out.
>> >>
>> >> #/bin/bash
>> >> for i in $(cat certificates.txt)
>> >> do
>> >> echo $i
>> >> done
>> >>
>> >> I expected this
>> >>
>> >> RSA Secure Server Certification Authority
>> >> VeriSign Class 1 CA Individual Subscriber-Persona Not Validated
>> >>
>> >>
>> >> but i got this
>> >>
>> >> RSA
>> >> Secure
>> >> Server
>> >> Certification
>> >> Authority
>> >> VeriSign
>> >> Class
>> >> 1
>> >> CA
>> >> Individual
>> >> Subscriber-Persona
>> >> Not
>> >> Validated
>> >>
>> >> any ideas how to fix this? i mean, how can i get the whole line
>> >> instead of word by word?
>>
>> Try adding:
>>
>> IFS=
>>
>> before the do command and see if that does it for you.
>>
>> Mikkel
>
> >
>
> Can't do it directly in front of the do statement, but if you put
it in front of the whole if statement, then the parsing works. *Now*
I have to research what that is doing! Thanks for making me learn
something today! :-)
>
> Kevin
>
>
Yes, I should have said to put it after #!/bin/bash.

What that does is set the parameter separator to an empty string. So
it uses the end of the line instead of space, <tab> and new line.
You can see what it is set to by using the set command, or by
running echo $IPS. You can find it in the bash man page.

Have fun.
Mikkel
- -- 
Do not meddle in the affairs of dragons, for thou art crunchy and
taste good with Ketchup!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAk81d/sACgkQqbQrVW3JyMQbZACfZ89NGAoKOdSrJY1wFX7Hv8/o
9lcAn1dfV6ghX+aedcTLo6czkZY4MU1U
=QJin
-----END PGP SIGNATURE-----

-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org


[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux