Sponsored Content
Top Forums Shell Programming and Scripting Perl scripting to get "Wanted Data" Post 302902126 by Aia on Sunday 18th of May 2014 10:54:44 PM
Old 05-18-2014
Quote:
Originally Posted by MacLing66
Thank Jethrow ...

09.05.2014 09.49.52:073 RID:routerNode1@cdmsapp1:1662691809,msisdn:9875434355,sid:34500116008034,tid:zd330106074,status:2,time:20140509094952,reaso
nSmilieELIVRD,refund:null,status2:null

the output :

09-05-2014,09-49-52,routerNode1@cdmsapp1:1662691809,9875434355,34500116008034,2,20140509094952

is it numeric for TID(column) ? if alphanumeric, the TID is missing.
how make it alphanumeric ?


and for the last line, how to print "\n", so the output make it perfect.

09-05-2014,09-49-52,routerNode1@cdmsapp1:1662712526,765433456,46500112042005,1927536832,96,20140509094952[user1@app1 current]$
Substitute the red for the green if you still want to make that code to work per your last comment.

Code:
perl -F'\s|,' -ane '$\=",";
	for $i (0..$#F) {
		@s=split(/:/,$F[$i]);
		if($i<=1) {
			$s[0]=~s/\./-/g;
			print $s[0].($i==1? $\="":"")
		}
		else {
			if($#s==2) {print ",$s[1]:$s[2]"}
			#else {print ",$s[1]" if $s[1]!=0}
                        else {print ",$s[1]" if $s[1] =~ /\d/}
		}
	}
#print "\n" if not eof' input.txt
print "\n"' input.txt

 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

2. Shell Programming and Scripting

perl folder list with "..", without ".".

Hi Everyone, if my folder "foldera" inside has one file. so if i do if ($df =~ /^\./) { next; } then i will get ### filea ### if i want to have ### .. filea ### means also display the parent .., how should i modify the perl ~// in my code? Thanks ---------- Post updated... (6 Replies)
Discussion started by: jimmy_y
6 Replies

3. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

4. Shell Programming and Scripting

how to use "cut" or "awk" or "sed" to remove a string

logs: "/home/abc/public_html/index.php" "/home/abc/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" "/home/xyz/public_html/index.php" how to use "cut" or "awk" or "sed" to get the following result: abc abc xyz xyz xyz (8 Replies)
Discussion started by: timmywong
8 Replies

5. Shell Programming and Scripting

perl - Removing dots(".") from the data

Hi Friends, I have a file1 as below file1.txt 100000.||1925-01-10|00:00|1862SHERMA NAVE#1SE.||EVTON|IL|60201||22509.|BDSS|62007|2639.|26670 100001.||1935-01-10|00:00|1862NEW . YRK NO.||EVTON|IL|60201||22509.|BDSS|62007|2639.|26670. 100002.||1965-01-10|00:00|1862 IND . INC,CL... (6 Replies)
Discussion started by: i150371485
6 Replies

6. Shell Programming and Scripting

Perl failure with "main::$fn" used only once:" in error logs

Hi all, Can anyone guess why this is happening? I am new to Perl, so please help me to fix this error: - I have a static html file which calls the cgi-perl script. HTML Code: <html> <head> <title> Hey Dude! </title> </head> <body> <form method="POST"... (3 Replies)
Discussion started by: bashily
3 Replies

7. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

8. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

9. AIX

Apache 2.4 directory cannot display "Last modified" "Size" "Description"

Hi 2 all, i have had AIX 7.2 :/# /usr/IBMAHS/bin/apachectl -v Server version: Apache/2.4.12 (Unix) Server built: May 25 2015 04:58:27 :/#:/# /usr/IBMAHS/bin/apachectl -M Loaded Modules: core_module (static) so_module (static) http_module (static) mpm_worker_module (static) ... (3 Replies)
Discussion started by: penchev
3 Replies
All times are GMT -4. The time now is 11:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy