Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6229925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:39:21+00:00 2026-05-24T09:39:21+00:00

So I have testfile which contains Line one Another line and this is the

  • 0

So I have testfile which contains

Line one
Another line
and this is the third line

My script reads this file, does some stuff and I end up with a variable that should contain it. Kind of doing

filevar=$(cat testfile)

(the important thing here is that I cannot access the file directly).

I’ll be using the contents of that variable to generate an HTML code and one things I have to do is to add <br> to the end of each line. The problem is, there doesnt seem to any EOLs in my var:

echo $filevar
Line one Another line and this is the third line

How do I read the file properly to keep the EOLs? Once I have that I can simply sed s/$/<br>/g, but till then…

thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T09:39:21+00:00Added an answer on May 24, 2026 at 9:39 am

    Instead of doing echo $filevar do echo "$filevar" (note the double quotes). This will send a single argument to echo and then you can pipe this to sed.

    With sed, this will be treated as 3 lines, so you do not need the g option. This works with me (bash and cygwin):

    echo "$filevar" | sed 's/$/<br>/'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an xml which contains some keywords. The format of the xml this:
I have a project A, which contains some java files and a classpath resource
I have this javascript code which makes possible writing in a file { var
I have a basic PHP script like this: <?php system(/bin/touch /root/testfile); When I run
I have been given a textfile which contains data on time sheet. That line
I have a simple input form which contains an input type=file with name=pdf_statement. I
I have some data which I run through, which generates a textfile. The data
I have a test file that contains tests taking quite a lot of time
I have a test file that has many lines, each line looks something like:
I have a test file that contains 1,2,3 2,3,4 5,6,7 I want to insert

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.