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 8827953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:29:46+00:00 2026-06-14T07:29:46+00:00

I need to add a header to an existing file in unix as a

  • 0

I need to add a header to an existing file in unix as a part of my requirement. For that I used ed text editor got from this discussion

How can I add a line to a file in a shell script?

This is the code I used

printf '0a\n%s\n.\nw\n',$header, | ed "./runtime/"$outputFileName

I obtained the value of $header from another file which is

"header 1","header 2","header 3"

After executing the script, When I check the output file the very first line of the file, contain only this line

1","header

How to make the whole line to get added in the output file? please help. Thanks in advance.

PS:I am using Sun Solaris

  • 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-06-14T07:29:48+00:00Added an answer on June 14, 2026 at 7:29 am

    be sure to use printf correctly. (1) quote header (2) separate arguments by spaces

    echo '"header 1","header 2","header 3"' > test.txt
    header="$(cat header.txt)"
    printf '0a\n%s\n.\nw\n' "$header"
    

    results in

    0a
    "header 1","header 2","header 3"
    .
    w
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a report that already has an existing header. I need to add
I need to add an header recursively to several file according to the name
I need to add submenu to Appearance menu at WordPress like Background, Header, etc.
I have several jsf pages. I need to add dynamic breadcrumbs to the header.xhtml.
I can't access a element with its href. Like this example, i need add
I need to add recurring events with start time and end time. I used
I need to add an header to a word document previously generated by a
I need to add a soap header to my web service. I plan to
So I got this program to run, but now any numbers that I input
I have a text file that has many records. Each record is a xml

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.