[CentOS] script regular expression

Steve Brooks steveb at mcs.st-and.ac.uk
Fri Feb 10 14:47:36 UTC 2012


On Thu, 9 Feb 2012, 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?

This will make it work your way.

--------------------------------------------------------------------
#!/bin/sh

IFS="
"
for i in `cat certificates.txt` ; do
   echo $i
done
--------------------------------------------------------------------

Cheers,

Steve


More information about the CentOS mailing list