Solved

perl split

Posted on 2013-12-28
2
199 Views
Last Modified: 2014-01-07
I have x numbers of file which has named with same algorithm

[root@sflow snmpstatus]# ls -l
total 20
-rw-r--r-- 1 root root  675 Dec 28 13:00 K16.Result.28-12-2013-13-00-04.txt
-rw-r--r-- 1 root root  720 Dec 28 13:00 K17.Result.28-12-2013-13-00-04.txt
-rw-r--r-- 1 root root 1015 Dec 28 13:00 ROUTER.Result.28-12-2013-13-00-04.txt
-rw-r--r-- 1 root root  697 Dec 28 13:00 T01.Result.28-12-2013-13-00-04.txt
-rw-r--r-- 1 root root 2201 Dec 28 13:00 T01.stat1.28-12-2013-13-00-04.txt

Open in new window


before the first dat there are names like K16 K17 ....

1 up 1000
2 up 1000
3 up 1000
4 up 1000
5 up 1000
6 up 1000
7 down 1000
8 up 1000
9 up 1000
10 up 1000
11 up 1000
12 up 1000
13 down 1000
14 down 1000
15 down 1000
16 down 1000
17 down 1000
18 down 1000
19 down 1000
20 down 1000
21 down 1000
22 down 1000
23 up 100
24 down 1000
25 up 100
26 down 1000
27 down 1000
28 down 1000
29 down 1000
30 down 1000
31 down 1000
32 down 1000
33 up 1000
34 up 1000
35 up 1000
36 up 100
37 up 1000
38 down 1000
39 up 1000
40 up 1000
41 down 1000
42 up 1000
43 up 1000
44 up 1000
45 down 1000
46 down 1000
47 down 1000
48 up 1000
1000 notPresent 0
1001 notPresent 0
1002 notPresent 0
1003 notPresent 0
1004 notPresent 0
1005 notPresent 0
1006 notPresent 0
1007 notPresent 0
100000 up 0

Open in new window



And they al have some includes like that so i want to split them write to line by line like that


K16 1 up  1000
K16 2 up  1000
....
K17 1 up  1000
....


how should i do it ?
0
Comment
Question by:3XLcom
2 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
ID: 39743369
If you are reading <> or <ARGV>, the name of the file will be in $ARGV
0
 

Author Closing Comment

by:3XLcom
ID: 39762528
sorry thank you
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
stftime format 4 56
Awk Question 2 129
Perl Application JSON Receiving Strange Java Error 3 76
Ned Perl Snippet to Read Files in Directory 5 74
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question