Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

202
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!