Solved

perl split

Posted on 2013-12-28
2
197 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

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…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

770 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