Cat Command

Solved
akhx Posted messages 1 Status Member -  
shadoxys Posted messages 3 Status Member -
Hello, I need to merge 3 text files into 1 and then separate them with ****** (aster). I can't figure out which command I could use in conjunction with Cat. I'm using Fedora 14.

Thank you in advance.

5 answers

  1. dubcek Posted messages 18627 Registration date   Status Contributor Last intervention   5 660
     
    hello
    (cat file1 ; echo "*****" ; cat file2 ; echo "******" ; cat file3) >file 
    or use head to have a separator
    head -999999 file1 file2 file3 >file 
    4
  2. Anonymous user
     
    hi,

    with cat only, I don't see how to do it :(
    well yes, if you have control of the terminal
    cat fic1 - fic2 - fic3

    you type *****, then Enter, then Ctrl-D, each time the command returns the terminal.
    but it's not very convenient ;)

    can you use other tools?

    with sed
    sed -s '$a*****' fic1 fic2 fic3

    with awk
    awk '{if(NR>FNR){NR=1; printf("%s\n%s\n","*****",$0)}else{print}}' fic1 fic2 fic3
    2
  3. shadoxys Posted messages 3 Status Member 1
     
    Thank you so much for your answers. It's exactly what I was looking for. This is my first time posting on this site and wow, what a result! Thank you for taking the time to respond to me. See you later, guys!
    1
  4. jeanbi Posted messages 15399 Registration date   Status Contributor Last intervention   2 383
     
    hello,
    cat file1 file2 file3 >file
    a+
    0
  5. shadoxys Posted messages 3 Status Member 1
     
    Pour this part it’s fine, actually what I would like to do is once the 3 texts are gathered, I would like to separate the texts in the new file with ***. Simply to be able to distinguish them.
    cat fichier1 fichier2 fichier3 > fichier | ??????
    Thank you
    0