![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Linux RedHat, Ubuntu, SUSE, Fedora, Debian, Mandriva, Slackware, Gentoo linux, PCLinuxOS. All Linux questions here! |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
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
|
|||
|
|||
|
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)}'
|
|||
| Google The UNIX and Linux Forums |