LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-31-2012, 05:42 AM   #1
balajiteja
LQ Newbie
 
Registered: Aug 2012
Location: india
Posts: 2

Rep: Reputation: Disabled
Thumbs up Hi guys Help Me in Scripting


Hi all,
here i am attaching two input files as well as two output files,can you guys please give me the script for these files
INPUT(1)- "23 Aug 2012 12:15:09 IST","Aug 23 12:13:45 AX2500 CAT-TDP-N: 192.168.10.2:6465400 <-->147.234.242.96:4435,147.234.242.96:4435 <-->182.19.88.230:6465400
OUTPUT(1)- 23 August 2012 12:13:45|AX2500|CAT-TDP-N|192.168.10.2|6465400|182.19.88.230|147.234.242.96|4435
INPUT(2)<134> Aug 23 12:13:46 AX2500 CAT-TDP-D: 192.168.10.2:569<-->8.8.8.8:533, 8.8.8.8:533<-->182.19.88.230:569
OUTPUT(2)- 134|23 Aug 2012 12:13:46|AX2500|CAT-TDP-D|192.168.10.2|8.8.8.8|533|182.19.88.230|569|
 
Old 08-31-2012, 05:48 AM   #2
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Um... You mean you want a script to convert the input into the output? The two files don't have a common format, how do you expect a script to do the conversion?
 
Old 08-31-2012, 05:52 AM   #3
balajiteja
LQ Newbie
 
Registered: Aug 2012
Location: india
Posts: 2

Original Poster
Rep: Reputation: Disabled
Hi snark

Quote:
Originally Posted by Snark1994 View Post
Um... You mean you want a script to convert the input into the output? The two files don't have a common format, how do you expect a script to do the conversion?
i need two different scripts for two input files to convert as output file..
i.e script 1 and script 2
 
Old 08-31-2012, 06:04 AM   #4
Snark1994
Senior Member
 
Registered: Sep 2010
Location: Wales, UK
Distribution: Arch
Posts: 1,632
Blog Entries: 3

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Ah I see. Well, you'll probably want to be looking at something like perl, ruby or python - you might just be able to do it with awk, but I don't think it'd be pretty.
 
Old 08-31-2012, 06:42 AM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Quote:
INPUT(1)-
"23 Aug 2012 12:15:09 IST","Aug 23 12:13:45 AX2500 CAT-TDP-N: 192.168.10.2:6465400 <-->147.234.242.96:4435,147.234.242.96:4435 <-->182.19.88.230:6465400
OUTPUT(1)-
23 August 2012 12:13:45|AX2500|CAT-TDP-N|192.168.10.2|6465400|182.19.88.230|147.234.242.96|4435

INPUT(2)
<134> Aug 23 12:13:46 AX2500 CAT-TDP-D: 192.168.10.2:569<-->8.8.8.8:533, 8.8.8.8:533<-->182.19.88.230:569
OUTPUT(2)-
134|23 Aug 2012 12:13:46|AX2500|CAT-TDP-D|192.168.10.2|8.8.8.8|533|182.19.88.230|569|
When you say "2 different scripts", I assume you mean that the rule to be applied is different between the two examples.

With only one example for each script, it's hard to see exactly what the rule should be.
 
Old 08-31-2012, 11:24 AM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 19,103

Rep: Reputation: 4381Reputation: 4381Reputation: 4381Reputation: 4381Reputation: 4381Reputation: 4381Reputation: 4381Reputation: 4381Reputation: 4381Reputation: 4381Reputation: 4381
Quote:
Originally Posted by balajiteja View Post
i need two different scripts for two input files to convert as output file..
i.e script 1 and script 2
Ok. Can you post what you've written/tried so far, and tell us where you're stuck?? We'll be glad to help, but we won't write your scripts for you. There are MANY thousands of scripting tutorials you can find via Google, if you looked.

Just by looking at what you posted, you can use sed to replace characters easily, so that could remove the "< >" characters, and replace the commas with "|" characters too. A simple compare in your shell script can look for "Aug" and output August instead, or you could also do that with sed as well, depending on how simple you want to keep things.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Hello guys Emisand LinuxQuestions.org Member Intro 1 02-16-2012 09:02 PM
LXer: Scripting the Linux desktop, Part 2: Scripting Nautilus LXer Syndicated Linux News 0 02-17-2011 04:02 AM
Firefox Scripting Add-on (Scripting HTML / Javascript inside Firefox) linuxbeatswindows Programming 1 09-18-2009 10:09 PM
teaching shell scripting: cool scripting examples? fax8 Linux - General 1 04-20-2006 04:29 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration