Output formatting prob.. guyz plz hlp


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Output formatting prob.. guyz plz hlp
# 1  
Old 06-23-2008
Output formatting prob.. guyz plz hlp

SmilieHi 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
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
W/o error checking wrt fields or contents:
Code:
cat file | while read LINE; do LINE=(${LINE//|/ })
 echo -en "Name: ${LINE[0]}\nLogin time: ${LINE[1]}\nLog out time: ${LINE[2]}\n\n"
done

# 3  
Old 06-23-2008
# 4  
Old 06-25-2008
Dear unSpawn when i incorporated ur suggestion in scrypt and got an error msg

Error msg: test.sh: Syntax error at line 1 : `(' is not expected.



Line that i hv incorporated in my scrypt is
cat login.txt | while read LINE; do LINE=(${LINE//|/ })
echo -en "Name: ${LINE[0]}\nLogin time: ${LINE[1]}\nLog out time: ${LINE[2]}\n\n"
done


Plz help
# 5  
Old 06-25-2008
Quote:
Originally Posted by anushree.a
Error msg: test.sh: Syntax error at line 1 : `(' is not expected.
Not using Bash? Try:
Code:
awk -F'|' '{print "Name:", $1, "\n", "Login time:", $2, "\n", "Log out time:", $3, "\n\n" }' inputfile

# 6  
Old 07-08-2008
Hey Thanx unSpawn, Finally it worked.. few probs are there to incorporate ur suggestion in my original script but i can manage it...
Thanx a lot yaar
Smilie all the best
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. Shell Programming and Scripting

Formatting ls output

I am using find and ls to search for "warez" files on my server. find /home/ -regex ".*\.\(avi\|mp3\|mpeg\|mpg\|iso\)" -print0 | xargs -0 ls -oh This command produces this: -rw-r--r-- 1 1000 3.2M Feb 18 2009 /home/user/public_html/lupus.mp3 I want to only get this 3.2M... (4 Replies)
Discussion started by: bonrad
4 Replies

3. Shell Programming and Scripting

more help with formatting ls output...

Ok, for a fun project, my goal is to replicate the style of "catalog" on an old apple ] *A 002 SOMEAPPLESOFTFILE B 004 SOMEFILE T 006 SOMETEXT I 002 SOMEINTEGERFILE The first character is either " " or "*" depending on if the file is locked or not. Next is the filetype, so in... (1 Reply)
Discussion started by: patrick99e99
1 Replies

4. Ubuntu

File opening prob. plz assist guys

Hi friends, this problem is pretty similar to the thread that i have generated earlier. If the TXT file that i have opened using "cat" is huge then my putty can only show me last few lines. Similarly if i use "more" command to open a huge TXT file then it asks to press any key to scroll up the... (9 Replies)
Discussion started by: anushree.a
9 Replies

5. Linux

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... (2 Replies)
Discussion started by: anushree.a
2 Replies

6. Shell Programming and Scripting

hi guyz

i require a script which can import the ip address and use it as an input to other. (3 Replies)
Discussion started by: din_annauniv
3 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