The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > Linux
Google UNIX.COM


Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Formatting Output dhanamurthy Shell Programming and Scripting 6 05-02-2008 08:43 AM
Formatting bdf output Cameron Shell Programming and Scripting 5 04-09-2008 06:05 AM
formatting output balaji_prk Shell Programming and Scripting 4 09-15-2007 06:23 AM
Formatting output illur81 Shell Programming and Scripting 3 10-13-2005 06:24 AM
Formatting the output Cameron Shell Programming and Scripting 7 02-15-2002 07:30 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 06-23-2008
Registered User
 

Join Date: May 2008
Posts: 59
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
Reply With Quote
Forum Sponsor
  #2  
Old 06-23-2008
joeyg's Avatar
Moderator
 

Join Date: Dec 2007
Location: Home of world champion Boston Celtics
Posts: 984
Wink 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
Reply With Quote
  #3  
Old 06-23-2008
Moderator
 

Join Date: Feb 2007
Posts: 2,332
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
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 11:08 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0