Output formatting problem..Plz hlp


 
Thread Tools Search this Thread
Operating Systems Linux Output formatting problem..Plz hlp
# 1  
Old 06-23-2008
Output formatting problem..Plz hlp

Hi guys,
It will be a great help if somebody can help me in following problem.
I have tried hard but because of lack of UNIX/LINUX knowledge I am not able to do it.
I have written a script that returns 3 things of all the employees in my organisation. i.e. Name, Login time & log out time of each and every employee. It returns the output in pipe-delimited format. For your ref. sending a small sample

e.g.
Deepti|083032|174501
Anushka|081705|190003
Neeraj|082715|173200



After getting this output I copy it to excel and convert that pipe-delimited txt to normal excel format by using “Text-to-columns” option in excel.
Then I use MS Word's “Mail Merge” function to arrange n print it in a particular format. For your ref. sending a small sample

e.g. (After using MS word's “Mail Merge” option, the document which is ready to print looks something like this)

Name: Deepti

Login time: 083032

Log out time: 174501




Name: Anushka

Login time: 081705

Log out time: 190003




Name: Neeraj

Login time: 082715

Log out time: 173200



This format then I print on a “PIN Mailer” (Continuous stationary)
Now, what my problem is, as you can see, I have to do lot of manual work in this log printing process.
Can I in any way automate it? Like, something which I can incorporate in my script which is giving me that pipe-delimited format.
Can I get a txt document that can be ready to print?

Waiting for reply.
And thanx in advance
# 2  
Old 06-23-2008
Hammer & Screwdriver Do you have to do all that Excel and Word stuff?

Before approaching from unix, Excel will read csv (comma separated values) files without having to do much of anything. I write to csv [use a , instead of | as delimiter] whenever I need to create something for my users that they will want to open in Excel.

What I am thinking is:
(a) create your "|" delimited file [coding already in-place]
(b) follow-up script to read that file and create a .txt output file

The follow-up would be roughly:

Code:
rm printfile.txt
while read zf
   do
   fld1=$(echo "$zf" | cut -d"|" -f1)
   fld2=$(echo "$zf" | cut -d"|" -f2)
   fld3=$(echo "$zf" | cut -d"|" -f3"
   echo "Name: "$fld1 >>printfile.txt
   echo " " >>printfile.txt
   echo ...
     {rest of echo lines per record}
done

# 3  
Old 06-23-2008
Try something like this:

Code:
your_script | awk -F "|" '{printf("Name: %s\n\nLogin time: %s\n\nLog out time: %s\n\n\n\n", $1, $2, $3)}'

Regards
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Problem in formatting output in sed / awk

I have a file like this : ! 1 ! 542255 ! 50,140.00 ! ! 2 ! 551717 ! 5,805.00 ! ! 3 ! 551763 ! 8,130.00 ! ! 4 ! 551779 ! 750.00 ! ! 5 ! 551810 ! 56,580.00 ! ! 6 ! 551816 ! 1,350.00 ! ! 7 ! 551876 ! 360.00 ! ! 8 ! 551898 ! ... (10 Replies)
Discussion started by: adam1969in
10 Replies

2. Shell Programming and Scripting

Output formatting problem

Hello; I have a simple loop filtering a log: for LU in $(< LU-list-Final) do OUT=$(grep -B1 $LU cibc-src-ip.cap |egrep 'IP 16|IP 19|IP 15' |awk -F">" '{print $1}') if ; then echo " LU $LU was accessed by ===============> $OUT " echo "" fi done The current output snippet looks like... (2 Replies)
Discussion started by: delphys
2 Replies

3. Shell Programming and Scripting

Problem in formatting output of SQL query in excel sheet in shell script

Hi Guys.. Need your help to format the output of my shell script. I am using spool command to take out put in csv file. below is my code. (for example) col USERNAME for a15 col EMAIL for a30 col FULL_NAME for a20 col LAST_LOGIN for a40 col DATE_CREATED for a40 SPOOL 120.csv... (3 Replies)
Discussion started by: Agupte
3 Replies

4. Shell Programming and Scripting

Need some Help for file filteration and saving the output in other directory using grep....plz ...

Hi all........ Plss do help me.......in a big trouble... :wall::wall::wall: I have 3 directories named as :1. /home/shuchi/source 2./home/shuchi/destination 3./home/shuchi/filter now the problem is /home/shuchi/source has say 2 files with extension .txt as given below : A.txt Code: ... (0 Replies)
Discussion started by: ektubbe
0 Replies

5. Shell Programming and Scripting

output formatting problem

I would like to keep the complete lines in the output, but my script adds carriage returns for each space (e.g. keep BRITISH AIRWAYS on one line in the output): File1= BAW BRITISH AIRWAYS RYR RYAN AIR for i in $(cat File1) do echo $i done Output: BAW BRITISH AIRWAYS RYR... (4 Replies)
Discussion started by: barny
4 Replies

6. Shell Programming and Scripting

Output formatting prob.. guyz plz hlp

:)Hi guys, I have written a script that returns 3 things of all the employees in my organisation. i.e. Name, Login time & log out time of each and every employee. It returns the output in pipe-delimited format. For your ref. sending a small sample e.g. Deepti|083032|174501... (5 Replies)
Discussion started by: anushree.a
5 Replies

7. UNIX for Dummies Questions & Answers

What is the output of that Shell Scripts Plz tell me

tr "" "" | sort | awk 'length($0)>0' | uniq -c (1 Reply)
Discussion started by: brain_full
1 Replies

8. UNIX for Dummies Questions & Answers

plz Help How should I configure cc compiler output file plz help???

i.e configuration of C compiler :confused: (4 Replies)
Discussion started by: atiato
4 Replies

9. UNIX for Dummies Questions & Answers

How to connect to the Internet Using RH 7.2 i.e configuration plz Hlp

How to connect to the Internet Using RH 7.2 i.e configuration plz Hlp.....cause I want to accsses to the Internet to download Help and application in the Red hat OS???? (1 Reply)
Discussion started by: atiato
1 Replies

10. UNIX for Dummies Questions & Answers

How to download Red hat plz Hlp ?

ftp://metalab.unc.edu/pub/Linux/distributions/ Hi all , I know how to go to the distibution site but How to download if using ftp I want to ask this Q:confused: (3 Replies)
Discussion started by: atiato
3 Replies
Login or Register to Ask a Question