Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

201
Visualizações
Linux merging files

I'm doing a linux online course but im stuck with a question, you can find the question below.

You will get three files called a.bf, b.bf and c.bf. Merge the contents of these three files and write it to a new file called abc.bf. Respect the order: abc.bf must contain the contents of a.bf first, followed by those of b.bf, followed by those of c.bf.

Example Suppose the given files have the following contents:

a.bf contains +++.

b.bf contains [][][][].

c.bf contains <><><>.

The file abc.bf should then have

+++[][][][]<><><>

as its content. I know how to merge the 3 files but when i use cat my output is:

+++
[][][]
<><><>

When i use paste my output is "+++ 'a lot of spaces' [][][][] 'a lot of spaces' <><><>"

My output that i need is +++[][][][]<><><>, i dont want the spaces between the content. Can someone help me?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

echo -n "$(cat a.bf)$(cat b.bf)$(cat c.bf)" > abc.bf

  • echo -n will not output trailing newlines
over 4 years ago · Santiago Trujillo Relatório

0

What you want to do is delete the newline characters.

With tr:

cat {a,b,c}.bf | tr --delete '\n' > abc.bf

With echo & sed:

echo $(cat {a,b,c}.bf) | sed -E 's/ //g' > abc.bf

With xargs & sed:

<{a,b,c}.bf xargs | sed -E 's/ //g' > abc.bf

Note that sed is only used to remove the spaces.

With cat & sed:

cat {a,b,c}.bf | sed -z 's/\n//g'
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda