LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Hi guys Help Me in Scripting (https://www.linuxquestions.org/questions/linux-newbie-8/hi-guys-help-me-in-scripting-4175424939/)

balajiteja 08-31-2012 05:42 AM

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|

Snark1994 08-31-2012 05:48 AM

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?

balajiteja 08-31-2012 05:52 AM

Hi snark
 
Quote:

Originally Posted by Snark1994 (Post 4769030)
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

Snark1994 08-31-2012 06:04 AM

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.

pixellany 08-31-2012 06:42 AM

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.

TB0ne 08-31-2012 11:24 AM

Quote:

Originally Posted by balajiteja (Post 4769035)
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.


All times are GMT -5. The time now is 06:31 PM.