I have a text file with 100 lines in it. I want to convert particular lines, lets say line1, line6 , line27, line 48, line 86, line99 to bold. I am using solaris 5.10, with KSH.

Is there a way I can achieve this, may be a text to html script would do this.

closed as unclear what you're asking by Anthon, Michael Homer, cuonglm, G-Man Says 'Reinstate Monica', Flup Jun 19 '15 at 7:55

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • What are you using to view the boldened text? "May be a text to html script" is a bit indefinite. Are you going to use a web browser? Or a PDF viewer. Does the text need to show bold when you do display with less (like a man-page)? – Anthon Jun 19 '15 at 4:43
  • @Anthon i wrote a script that'll generate a comma seperated txt file. Before i use this file in Excel, i want to bold some lines. I dont want to go to excel and bold them there. – ayrton_senna Jun 19 '15 at 4:48
  • If you want to view these simple csv files in Excel, you should convert them to .xlsx (or .xls) and do the boldening on the fly. AFAIK there are no standard tools for that, but it can be done with e.g. Python and openpyxl or xlwt – Anthon Jun 19 '15 at 4:55
  • Text files contain text. Nothing else. An application might read a text file, and decide that, based on some tag or another, that the following text ought to be displayed in a way you'd consider bold, but text is never bold - only sometimes it is displayed so. less will bold overstrikes so the sequence: printf 'b\bbo\bol\bld\bd\n' |less should get the word bold displayed, because each letter is printed twice: once preceding a backspace and then again immediately following one. – mikeserv Jun 19 '15 at 5:03

Based on the append to the main post - you seem to be looking for a formatted file that can be opened int Excel.

It is more advisable then to convert the entire file to an HTML table, with your particular lines been converted to bold.

If it is a simple CSV ( with no commas used purely as separators and not occuring within the columns itself) then you can do the following to convert it to an html.

     sed 's/^/<tr><td>/g; s/$/<\/td><\/tr>/g ; s/,/<\/td><td>/g ; $s/$/<\/table>/ ;1s/^/<table>/' yourfile.csv > yourfile.html

Remember this will convert it only to an HTML file that can be opened in Excel. To bold a specific line you can add the following command to the set of sed commands (lets say you want to bold the 5th line)

    5s/<td>/<td><b>/g; 5s/<\/td>/<\/b><\/td>/g

Not the answer you're looking for? Browse other questions tagged or ask your own question.