Format a file through unix script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Format a file through unix script
# 1  
Old 11-17-2010
Format a file through unix script

Hi,

Can you please help me out about how to format a .csv file through unix script?
Set of complete commands would be useful or also share few links if available.

---------- Post updated at 09:00 PM ---------- Previous update was at 08:59 PM ----------

I am talking about in terms of font, size, color change through script.
hOW WE CAN DO IT ON A FILE WHICH CONTAINS VARIOUS HEADINGS AND NORMAL TEXT.
# 2  
Old 11-17-2010
You need to be more precise. You cannot change font unless you use a specially formatted file like rich text. This is more of a windows thing. Color usually requires html. If the file is supposed to be straight ascii, then you can use ANSI escpae codes.

Are you creating a mail message?

What are you trying to do exactly? We need font name, colors, and so on.
# 3  
Old 11-18-2010
Lets foget about the color for the moment.
I have generated a .csv file. but before i use that in windows as I am emailing it to the ids, I want to change the font and size especially for the few static lines in the file. for eg: whatever i am echo'ingin the file, i want to display as bold in the .csv file.

Please let me know if you want some more inforamtion on this.

---------- Post updated 11-18-10 at 12:01 AM ---------- Previous update was 11-17-10 at 09:24 PM ----------

Can anyone help me out with my below query please?
I think I just require an example/syntax to do the same.
# 4  
Old 11-18-2010
None of this is just simple shell script code

I think you need to reconsider some of your assumptions about windows files. Once you do this: it is no longer a csv file that Excel can read. You will have retain and also email a separate real csv file for excel users. A csv file is not meant to be read as display in a PC mail window with an html rendering engine. csv and html are two entirely different beasts. And in windows: to get fonts, as I already said, requires special formatting. Not csv.

You'll need to write a small perl script. There are some perl tools already out there:
Text::InHTML - search.cpan.org
This simply converts text to html, you can use sed to add extra font & bold tags. It creates everything as the same font.

.xls format files directly support fonts, bold colors, etc.
You can download staroffice. It has an API that will let you create .xls compatible files for windows office.
This requires a lot of C coding. There are similar perl modules, they require perl code to make them work.

Someone may have written a big set of shell/perl scripts to do some of this, but I do not know anything about it.
Because of the way Microsoft chose to format .xls files, most shell tools are somewhat clumsy for creating packed structs. python, perl, and ruby can all do that for you easily.

Last edited by jim mcnamara; 11-18-2010 at 08:14 AM..
# 5  
Old 11-18-2010
Jim, Thanks alot for your help. It was really a helpful information fr me.
However, can I do this font change etc formatiing in.xls file through shell scripting?
If not then I will pick one of the alternative provided by you above Smilie
# 6  
Old 11-25-2010
I still require help on this Please:
The problem is: In bash shell, when I am sending a file through attachment to the email ids then the format is getting changed. for eg: the file (.txt or .csv) looks fine on the unix box, but when I attach it and send it to the email id, the format get changed. All new lines comes in the same line and it looks so weird without new line.
I am not bother about the file extension, it could be anything .csv or .txt or anyother but data should display properly when send it to email ids.
How can I acheive this?
# 7  
Old 11-25-2010
please clarify input and desired output.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

UNIX/PERL script to convert XML file to pipe delimited format

Hello, I need to get few values from a XML file and output needs to be written in another file with pipe delimited format. The Header & Footer of the Pipe Delimited file will be constant. The below is my sample XML file. I need to pull the values in between the XML tags <Operator_info to... (15 Replies)
Discussion started by: karthi1305561
15 Replies

2. Shell Programming and Scripting

Script to generate Excel file or to SQL output data to Excel format/tabular format

Hi , i am generating some data by firing sql query with connecting to the database by my solaris box. The below one should be the header line of my excel ,here its coming in separate row. TO_CHAR(C. CURR_EMP_NO ---------- --------------- LST_NM... (6 Replies)
Discussion started by: dani1234
6 Replies

3. Shell Programming and Scripting

UNIX shell script to format output report

i am new to unix shell scripting, could someone please help me. i was asked to develop a unix script and requirement of the script is as follows: 1. In source directory, if any new files are being dropped by external system then an email should be sent out with a message saying "files are... (3 Replies)
Discussion started by: crefi1545
3 Replies

4. Shell Programming and Scripting

Change the date and time format in UNIX script.

Hi, I am extracting a date string from the source file like this : 06/05/2014 16:04:00 I want to change it to 05-JUN-14 04.05.00.000000000 PM I basically store the date in a variable. I got solutions to change date in dd-mmm-yyyy format using tr but I guess it works only with the "date"... (8 Replies)
Discussion started by: Varshha
8 Replies

5. Shell Programming and Scripting

How to identify whether the script is in Unix format or not ?

Hi All, I have the below scenario in my environment Developers used to copy file from windows to Linux box. Some time on the copied file developers miss to run the dos2unix utility. Because of this script gets failed during the execution. Most of the failures are due to the dos2unix format... (7 Replies)
Discussion started by: kalpeer
7 Replies

6. Shell Programming and Scripting

Need a unix script to convert date into Julian format in a text file

The 6th & 7th column of the text files represents date & time. I need this to be converted in julian format using command "date +%s -d <date>". I know the command, but dont know how to use it on the script 0 dbclstr-b IXT_Web Memphis_Prod_SQL_Full Memphis-Prod-SQL-Full-Application-Backup... (4 Replies)
Discussion started by: ajiwww
4 Replies

7. Shell Programming and Scripting

Converting windows format file to unix format using script

Hi, I am having couple of files which i used to copy from windows to Linux, so now in case of text files (CTRL^M) appears at end of line. I know i can convert this windows format file to unix format file by running dos2unix. My requirement here is that i want to do it automatically using a... (5 Replies)
Discussion started by: sarbjit
5 Replies

8. Shell Programming and Scripting

Convert UNIX file format to PC format

Hi All, Is there any way to convert a file which is in UNIX format to a PC format.... Flip command can be used , apart form this command can we have any other way.... like usinf "awk" etc ..... main purpose of not using flip is that my Kshell doesnot support this comamnd.... (2 Replies)
Discussion started by: Samtel
2 Replies

9. UNIX for Dummies Questions & Answers

Convert UNIX file format to PC format

Hi All, Is there any way to convert a file which is in UNIX format to a PC format.... Flip command can be used , apart form this command can we have any other way.... like usinf "awk" etc ..... main purpose of not using flip is that my Kshell doesnot support this comamnd.... (1 Reply)
Discussion started by: Samtel
1 Replies

10. UNIX for Dummies Questions & Answers

Unix script to convert .csv file to.xls format

I have a .csv file in Unix box i need a UNIX script to convert the.csv files to.xls format. Its very urgent please help me. (1 Reply)
Discussion started by: moon_friend
1 Replies
Login or Register to Ask a Question