[CentOS] for loop example

Tue Jun 7 12:19:14 UTC 2016
Diego <diegofull at gmail.com>

Maybe this don't to be the best form to solve your problem, but worked,rs.

#!/bin/bash
#power by Diego Rodrigues

totalFileOne=$(wc -l file1 | cut -d" " -f1)
totalFileTwo=$(wc -l file2 | cut -d" " -f1)

count=0

if [ ! "${totalFileOne}" -eq "${totalFileTwo}" ];then
    echo "The two files need of same number of lines"
    exit 1
fi


for ((i=0;$i<${totalFileOne};i++));
do
    #add more one to some
    NumberLine=$(( $i+1 ))
    echo -en $(sed ${NumberLine}'!d' file1 ;sed ${NumberLine}'!d' file2)"\n"
done


Em ter, 7 de jun de 2016 às 08:42, <centos-request at centos.org> escreveu:

> Send CentOS mailing list submissions to
>         centos at centos.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://lists.centos.org/mailman/listinfo/centos
> or, via email, send a message with subject or body 'help' to
>         centos-request at centos.org
>
> You can reach the person managing the list at
>         centos-owner at centos.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of CentOS digest..."
>
>
> Today's Topics:
>
>    1. for loop example (Indunil Jayasooriya)
>    2. remote backup (Alessandro Baggi)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Sat, 4 Jun 2016 11:11:21 +0530
> From: Indunil Jayasooriya <indunil75 at gmail.com>
> To: CentOS mailing list <centos at centos.org>
> Subject: [CentOS] for loop example
> Message-ID:
>         <CAJF2yJSdCEysBoqGo2B+BerpgPYBmMxD=ahj4LiHN6xR8H=
> 3Gg at mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> Hi list,
>
> Can you look in to this?
>
>
> [root at centos67 loop]# cat file1
> firstname1
> firstname2
>
> [root at centos67 loop]# cat file2
> lastname1
> lastname2
>
> I need a OUTPUT like this
>
>
> *firstname1 lastname1firstname2 lastname2*
>
>
> But I try the below command , i get below output.  what is the real command
> to get the above output
>
> [root at centos67 loop]# for line1 in $(cat file1 ); do for line2 in $(cat
> file2 ); do echo "$line1" "$line2";done;done;
> firstname1 lastname1
> firstname1 lastname2
> firstname2 lastname1
> firstname2 lastname2
>
>
> And also, I created a file3 like this
>
> [root at centos67 loop]# cat file3
> firstname1 lastname1
> firstname2 lastname2
>
> How can I get the same OUTPUT ?
>
>
> *firstname1 lastname1firstname2 lastname2*
>
>
> if I try below command, i get the below output.
>
> [root at centos67 loop]# for i in $(cat file3);do echo $i;done;
> firstname1
> lastname1
> firstname2
> lastname2
>
>
> Could you pls help me to solve this ? THIS is very important to me.
>
>
>
>
>
>
>
>
>
> --
> cat /etc/motd
>
> Thank you
> Indunil Jayasooriya
> http://www.theravadanet.net/
> http://www.siyabas.lk/sinhala_how_to_install.html   -  Download Sinhala
> Fonts
>
>
> ------------------------------
>
> Message: 2
> Date: Sat, 4 Jun 2016 12:34:40 +0200
> From: Alessandro Baggi <alessandro.baggi at gmail.com>
> To: CentOS <centos at centos.org>
> Subject: [CentOS] remote backup
> Message-ID: <5752AEC0.4010609 at gmail.com>
> Content-Type: text/plain; charset=iso-8859-15; format=flowed
>
> Hi list,
> i've need to backup a partition of ~200GB with a local connection of 8/2
> mbps.
>
> Tool like bacula, amanda can't help me due to low bandwidth in local
> server.
>
> I'm thinking rsync will be a good choice.
>
> What do you think about?
>
> Thanks in advance.
>
>
> ------------------------------
>
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> https://lists.centos.org/mailman/listinfo/centos
>
>
> End of CentOS Digest, Vol 137, Issue 5
> **************************************
>