I have an Akka program with threads that are spending most of their time in the futex_ state.
This is from an Akka program that isn't doing much. I am not familiar with the internals of Akka, so I'm not sure if this is normal or not.
F S UID PID PPID LWP C PRI NI ADDR SZ WCHAN TTY TIME CMD
4 S 1 19 0 19 0 80 0 - 1149556 futex_ ? 0:00 /usr/bin/java
5 S 1 19 0 25 0 80 0 - 1149556 futex_ ? 0:04 /usr/bin/java
1 S 1 19 0 26 0 80 0 - 1149556 futex_ ? 0:00 /usr/bin/java
1 S 1 19 0 27 0 80 0 - 1149556 futex_ ? 0:00 /usr/bin/java
1 S 1 19 0 28 0 80 0 - 1149556 futex_ ? 0:00 /usr/bin/java
1 S 1 19 0 29 0 80 0 - 1149556 futex_ ? 0:00 /usr/bin/java
1 S 1 19 0 30 1 80 0 - 1149556 futex_ ? 0:12 /usr/bin/java
1 S 1 19 0 31 0 80 0 - 1149556 futex_ ? 0:04 /usr/bin/java
1 S 1 19 0 32 0 80 0 - 1149556 futex_ ? 0:00 /usr/bin/java
1 S 1 19 0 33 0 80 0 - 1149556 futex_ ? 0:00 /usr/bin/java
1 S 1 19 0 43 0 80 0 - 1149556 futex_ ? 0:02 /usr/bin/java
1 S 1 19 0 44 0 80 0 - 1149556 futex_ ? 0:00 /usr/bin/java
1 S 1 19 0 45 0 80 0 - 1149556 futex_ ? 0:00 /usr/bin/java
1 S 1 19 0 46 0 80 0 - 1149556 futex_ ? 0:01 /usr/bin/java
1 S 1 19 0 47 0 80 0 - 1149556 futex_ ? 0:02 /usr/bin/java
1 S 1 19 0 50 0 80 0 - 1149556 futex_ ? 0:00 /usr/bin/java
1 S 1 19 0 53 0 80 0 - 1149556 futex_ ? 0:01 /usr/bin/java
1 S 1 19 0 60 0 80 0 - 1149556 futex_ ? 0:03 /usr/bin/java
1 S 1 19 0 121 0 80 0 - 1149556 futex_ ? 0:00 /usr/bin/java
1 S 1 19 0 122 0 80 0 - 1149556 futex_ ? 0:01 /usr/bin/java
1 S 1 19 0 123 0 80 0 - 1149556 ep_pol ? 0:00 /usr/bin/java
1 S 1 19 0 282 0 80 0 - 1149556 futex_ ? 0:00 /usr/bin/java
1 S 1 19 0 283 0 80 0 - 1149556 futex_ ? 0:00 /usr/bin/java
1 S 1 19 0 284 0 80 0 - 1149556 futex_ ? 0:00 /usr/bin/java
1 S 1 19 0 285 0 80 0 - 1149556 futex_ ? 0:00 /usr/bin/java
1 S 1 19 0 295 0 80 0 - 1149556 futex_ ? 0:01 /usr/bin/java
1 S 1 19 0 383 0 80 0 - 1149556 futex_ ? 0:00 /usr/bin/java
1 S 1 19 0 433 0 80 0 - 1149556 futex_ ? 0:01 /usr/bin/java
1 S 1 19 0 1109 0 80 0 - 1149556 futex_ ? 0:00 /usr/bin/java
Checking the syscalls, there are a ton of timed out futex calls constantly happening. Here's a snippet from just a fraction of a second:
[pid 43] futex(0x7f36266dfc28, FUTEX_WAKE_PRIVATE, 1) = 0
[pid 43] futex(0x7f36266dfc54, FUTEX_WAIT_BITSET_PRIVATE, 1, {tv_sec=14532, tv_nsec=950443844}, 0xffffffff <unfinished ...>
[pid 47] <... futex resumed> ) = -1 ETIMEDOUT (Connection timed out)
[pid 47] futex(0x7f3626f8ab28, FUTEX_WAKE_PRIVATE, 1) = 0
[pid 47] futex(0x7f3626f8ab54, FUTEX_WAIT_BITSET_PRIVATE, 1, {tv_sec=14532, tv_nsec=954449564}, 0xffffffff <unfinished ...>
[pid 33] <... futex resumed> ) = -1 ETIMEDOUT (Connection timed out)
[pid 33] futex(0x7f3624a11128, FUTEX_WAKE_PRIVATE, 1) = 0
[pid 33] futex(0x7f3624a11154, FUTEX_WAIT_BITSET_PRIVATE, 1, {tv_sec=14532, tv_nsec=998037087}, 0xffffffff <unfinished ...>
[pid 43] <... futex resumed> ) = -1 ETIMEDOUT (Connection timed out)
[pid 43] futex(0x7f36266dfc28, FUTEX_WAKE_PRIVATE, 1) = 0
[pid 43] futex(0x7f36266dfc54, FUTEX_WAIT_BITSET_PRIVATE, 1, {tv_sec=14532, tv_nsec=960733704}, 0xffffffff <unfinished ...>
[pid 47] <... futex resumed> ) = -1 ETIMEDOUT (Connection timed out)
[pid 47] futex(0x7f3626f8ab28, FUTEX_WAKE_PRIVATE, 1) = 0
[pid 47] futex(0x7f3626f8ab54, FUTEX_WAIT_BITSET_PRIVATE, 1, {tv_sec=14532, tv_nsec=964665830}, 0xffffffff <unfinished ...>
[pid 43] <... futex resumed> ) = -1 ETIMEDOUT (Connection timed out)
[pid 43] futex(0x7f36266dfc28, FUTEX_WAKE_PRIVATE, 1) = 0
[pid 43] futex(0x7f36266dfc54, FUTEX_WAIT_BITSET_PRIVATE, 1, {tv_sec=14532, tv_nsec=971001771}, 0xffffffff <unfinished ...>
[pid 47] <... futex resumed> ) = -1 ETIMEDOUT (Connection timed out)
[pid 47] futex(0x7f3626f8ab28, FUTEX_WAKE_PRIVATE, 1) = 0
[pid 47] futex(0x7f3626f8ab54, FUTEX_WAIT_BITSET_PRIVATE, 1, {tv_sec=14532, tv_nsec=973981797}, 0xffffffff <unfinished ...>
[pid 43] <... futex resumed> ) = -1 ETIMEDOUT (Connection timed out)
[pid 43] futex(0x7f36266dfc28, FUTEX_WAKE_PRIVATE, 1) = 0
[pid 43] futex(0x7f36266dfc54, FUTEX_WAIT_BITSET_PRIVATE, 1, {tv_sec=14532, tv_nsec=980553240}, 0xffffffff <unfinished ...>
[pid 47] <... futex resumed> ) = -1 ETIMEDOUT (Connection timed out)
My theory is that this may be the Akka actors rapidly checking to see if there's any new work for them to do, but I am seeking confirmation if that is a valid theory. Thank you!
Recently I needed to speed up a legacy project(use zend framework 1.10.2),that project use zend_cache,I am new in zend framework.
the default.ini configure:
data.cache.interim.frontend.name = "Core"
data.cache.interim.frontend.options.lifetime = 311040000 ; 10 years
data.cache.interim.backend.name = "File"
data.cache.interim.backend.options.cache_dir = "/cache/dp-interim/"
data.cache.interim.backend.options.hashed_directory_level = 3
There have 506790 cache files in /cache/dp-interim (run command: ls -lR | grep "^-" | wc -l on /cache/dp-interim get the result).
run "iotop",get the result: TOTAL DISK READ : 1034.22K/s
run "iostat",the result:
avg-cpu: %user %nice %system %iowait %steal %idle
1.80 0.00 0.77 51.80 0.00 45.62
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
xvdap1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
xvdb 48.00 0.00 245.00 0.00 2344.00 0.00 9.57 1.51 6.16 3.95 96.80
xvdap3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
xvdf 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
avg-cpu: %user %nice %system %iowait %steal %idle
2.05 0.00 1.03 45.90 0.00 51.03
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
xvdap1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
xvdb 43.00 0.00 214.00 0.00 2056.00 0.00 9.61 1.10 5.20 4.47 95.60
xvdap3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
xvdf 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
avg-cpu: %user %nice %system %iowait %steal %idle
2.06 0.00 0.26 46.91 0.00 50.77
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
xvdap1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
xvdb 62.00 0.00 196.00 0.00 2064.00 0.00 10.53 1.64 8.33 5.06 99.20
xvdap3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
xvdf 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
qavg-cpu: %user %nice %system %iowait %steal %idle
2.33 0.00 2.59 45.34 0.00 49.74
Device: rrqm/s wrqm/s r/s w/s rsec/s wsec/s avgrq-sz avgqu-sz await svctm %util
xvdap1 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
xvdb 33.00 0.00 331.00 0.00 2912.00 0.00 8.80 0.99 3.01 2.68 88.80
xvdap3 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
xvdf 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00 0.00
It is the larger cache file cause the IO height?
Thanks for you help!
Is there any way to load read-only variables into memory before forking and keep them there without using up virt memory x number of children?
It seems to be a common opinion that read-only memory is shared by default and is copied on write. I ran a test and found this to be untrue:
#!/usr/bin/perl
my $data;
$$data = 'a'x 1_000_000; #keep it in a ref just in case that matters
foreach (0..10){
last unless my $pid = fork();
}
<STDIN>;
While the process is sitting on STDIN, I check top:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
15982 wdev 20 0 121m 2540 188 S 0.0 0.1 0:00.00 foo.t
15983 wdev 20 0 121m 2540 188 S 0.0 0.1 0:00.00 foo.t
15984 wdev 20 0 121m 2540 188 S 0.0 0.1 0:00.00 foo.t
15985 wdev 20 0 121m 2540 188 S 0.0 0.1 0:00.00 foo.t
15986 wdev 20 0 121m 2540 188 S 0.0 0.1 0:00.00 foo.t
15987 wdev 20 0 121m 2540 188 S 0.0 0.1 0:00.00 foo.t
15988 wdev 20 0 121m 2540 188 S 0.0 0.1 0:00.00 foo.t
15989 wdev 20 0 121m 2540 188 S 0.0 0.1 0:00.00 foo.t
15990 wdev 20 0 121m 2540 188 S 0.0 0.1 0:00.00 foo.t
15991 wdev 20 0 121m 2540 188 S 0.0 0.1 0:00.00 foo.t
15992 wdev 20 0 121m 2540 188 S 0.0 0.1 0:00.00 foo.t
Sure enough, practically all the memory is in individual child processes.
Is there something I am missing, or does forking a perl process really copy over the entire set of data structures for each child?
Either this is operating-system dependent or you're not seeing what you think you're seeing. I modified your test script to:
#!/usr/bin/env perl
print `free`;
my $data = [ ('a') x 1000000 ];
for (1 .. 10) {
print `free`;
last unless fork;
}
sleep 10;
Running it with ./forktest | grep Mem, I get output such as:
Mem: 3979908 2866552 1113356 0 667388 1258560
Mem: 3979908 2917888 1062020 0 667388 1258560
Mem: 3979908 2918284 1061624 0 667388 1258560
Mem: 3979908 2918532 1061376 0 667388 1258560
Mem: 3979908 2918936 1060972 0 667388 1258560
Mem: 3979908 2919404 1060504 0 667388 1258560
Mem: 3979908 2919900 1060008 0 667388 1258560
Mem: 3979908 2919900 1060008 0 667388 1258560
Mem: 3979908 2920148 1059760 0 667388 1258560
Mem: 3979908 2920148 1059760 0 667388 1258560
Mem: 3979908 2920496 1059412 0 667388 1258560
in which the second column of numbers (third column overall) is the total system RAM usage. Note that it increases from 2866552 to 2917888 when $data is assigned at the start of the program, then stays fairly steady from there on as the forks are done.
I suspect that what you're seeing in top is that it uses "shared memory" in the IPC-specific sense (i.e., chunks of memory which have been explicitly requested and allocated as "shared") and pages which are currently available to multiple processes on a copy-on-write basis do not meet that definition.
The perl docs on fork say "File descriptors (and sometimes locks on those descriptors) are shared, while everything else is copied."
I'm very new to matlab and am more of an ArcGIS user but I'd like to know how I can read asc files into Matlab and read coordinates.
The asc file is as follows (sorry it is huge!)
ncols 32
nrows 32
xllcenter -58.75
yllcenter -38.75
cellsize 2.5
NODATA_value -999
0.00 0.62 0.60 0.38 1.22
0.52 1.09 0.76 0.00 0.94
0.37 0.52 0.71 0.71 1.38
0.13 0.00 0.00 0.00 1.46
0.00 0.00 0.97 0.00 0.41
0.00 0.00 0.41 0.83 0.00
0.00 0.19 0.32 0.00 0.00
0.00 0.86 0.00 0.52 1.34
0.00 1.29 0.00 0.00 1.40
0.83 0.00 0.00 0.00 0.00
0.00 0.00 1.09 0.20 0.00
0.43 0.00 0.96 0.78 0.26
0.00 0.70 0.00 0.92 0.29
0.00 1.19 0.00 1.24 0.73
0.00 1.41 0.00 0.97 1.01
0.66 0.00 0.01 0.67 0.67
0.32 0.69 1.41 0.00 0.08
0.92 0.00 0.00 0.40 0.00
0.00 0.00 0.00 1.27 1.24
0.22 0.00 0.00 0.76 0.86
0.00 0.05 0.67 0.29 0.00
0.00 0.04 0.00 0.00 1.18
0.46 0.20 0.00 0.81 0.00
0.00 0.00 1.35 0.40 1.03
0.94 0.90 0.80 0.26 0.73
0.69 0.36 0.70 0.00 0.00
0.42 1.23 0.00 1.24 0.52
0.00 0.54 1.39 1.44 0.00
1.18 0.10 0.00 0.00 0.78
1.33 0.58 0.00 0.00 0.00
0.00 0.92 0.00 0.00 0.00
1.03 0.00 0.00 0.00 0.00
0.66 0.92 0.73 0.00 0.99
0.00 0.00 1.39 0.49 0.97
0.00 1.29 0.00 1.41 1.06
0.00 1.00 0.00 0.00 0.00
0.00 0.32 0.69 1.26 0.00
0.00 0.71 0.00 1.08 1.16
0.00 0.00 0.48 0.00 1.17
0.24 0.00 0.00 0.41 0.00
1.24 1.30 0.00 0.00 0.00
0.00 1.23 0.00 0.15 0.00
0.00 0.19 0.00 0.00 1.17
1.41 0.00 0.15 0.48 0.20
1.29 0.00 0.22 0.55 0.00
0.00 0.81 0.00 0.00 0.00
0.00 1.18 1.18 0.00 0.75
1.05 1.18 1.35 0.00 0.82
0.00 0.00 0.25 0.52 0.00
0.00 1.27 1.46 0.00 1.24
0.00 1.03 1.21 0.81 0.00
0.57 0.00 0.00 0.00 0.00
1.06 0.00 1.29 0.70 0.00
0.00 1.01 0.00 0.00 0.00
0.21 0.95 0.00 0.00 0.00
1.23 1.08 0.00 0.00 0.00
0.11 0.00 0.00 0.00 0.00
0.00 0.00 0.76 0.00 0.68
0.10 0.64 0.00 0.72 0.00
1.34 0.53 0.00 0.18 0.00
0.00 0.25 0.22 0.00 0.00
0.00 0.67 0.37 0.00 0.08
0.02 0.00 0.00 0.94 0.52
0.83 0.64 0.00 0.93 1.40
1.03 0.50 0.00 1.20 0.00
0.68 0.00 0.00 1.15 1.20
0.00 0.00 0.00 0.93 0.00
1.25 0.94 1.37 0.00 0.00
0.00 0.77 0.00 1.15 0.66
0.00 1.45 0.00 1.48 0.00
0.36 0.00 0.34 0.00 0.00
1.22 0.74 0.00 0.00 1.17
0.00 0.59 0.00 0.00 1.18
1.32 1.31 1.21 0.45 1.06
0.00 0.18 0.21 0.79 0.47
0.00 0.47 0.00 0.53 0.76
0.00 0.92 0.00 0.00 1.23
1.45 0.00 0.00 0.00 0.00
1.02 0.00 0.00 0.46 0.00
0.00 0.00 0.00 0.38 1.25
0.00 1.25 0.00 0.42 0.17
0.00 0.97 0.20 0.00 0.00
0.31 0.20 0.00 0.00 0.00
0.00 0.70 0.66 0.00 1.15
0.00 0.00 0.91 1.10 0.00
0.12 0.73 0.00 0.19 0.00
1.01 0.00 0.44 0.00 0.21
0.00 0.00 0.00 0.00 0.91
0.01 0.00 1.28 0.00 0.00
0.00 0.16 0.50 0.00 0.00
1.50 0.10 0.00 0.00 0.00
0.07 0.07 0.00 0.00 0.00
0.00 0.00 0.00 0.00 0.88
0.00 0.43 0.00 0.00 0.00
0.00 1.23 0.00 1.41 0.33
0.00 0.74 0.00 0.00 0.00
0.74 0.76 0.15 1.07 0.00
0.00 0.00 0.00 1.34 1.20
0.00 0.00 0.00 0.00 0.43
0.22 0.00 1.02 0.99 0.80
0.91 0.75 0.02 0.00 0.18
0.25 0.00 0.52 0.60 0.00
1.11 0.43 0.00 0.00 0.83
1.02 0.76 0.20 0.00 1.24
0.00 0.00 0.00 1.21 0.00
0.00 0.00 0.00 0.00 0.25
0.00 0.00 0.00 0.00 0.87
0.00 0.00 0.00 1.47 1.22
0.86 0.00 0.96 0.60 0.70
0.38 0.09 0.85 1.18 0.49
0.03 0.00 0.00 1.23 0.00
0.00 0.00 0.00 1.06 0.00
1.01 1.39 1.01 0.00 0.00
0.00 0.00 0.00 0.00 1.31
0.00 0.75 0.00 1.22 0.81
1.07 0.00 0.00 0.00 1.12
1.05 0.70 0.13 0.64 1.30
0.00 0.00 0.53 0.47 0.03
0.00 0.00 0.10 1.38 1.32
0.00 1.25 0.00 0.91 0.67
0.00 0.00 0.00 0.00 0.00
1.00 1.14 0.00 0.00 0.52
0.00 0.02 0.15 0.01 0.90
0.00 0.00 0.70 0.00 0.00
0.00 0.00 0.00 0.00 0.00
0.12 0.72 0.00 0.00 0.04
0.01 0.00 0.00 1.11 1.43
0.91 0.34 0.97 0.00 0.07
0.00 0.00 0.00 0.00 0.93
0.00 0.93 0.00 0.00 0.00
0.93 0.00 0.88 0.29 0.00
0.00 1.50 0.00 0.05 0.00
0.00 0.00 0.00 0.76 1.26
0.00 0.43 0.55 0.40 0.28
0.00 0.07 0.51 0.51 0.00
0.76 0.00 0.00 0.41 0.10
1.16 0.07 0.00 0.00 0.65
0.00 0.21 0.00 0.00 1.41
0.00 1.31 0.19 1.44 0.00
0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.00 0.94 0.00
1.12 0.68 0.00 0.00 0.81
0.00 0.00 0.00 0.96 0.00
0.38 0.00 0.00 0.46 0.00
1.15 0.36 0.70 1.04 0.89
1.47 1.20 0.00 0.35 0.00
0.49 0.00 0.00 1.48 0.00
0.00 0.45 1.42 0.00 1.12
0.00 0.00 1.20 1.27 0.00
0.00 0.68 0.30 0.00 0.00
1.20 0.00 0.89 0.00 0.00
0.00 0.00 0.00 0.00 0.00
0.00 1.10 0.48 1.48 0.00
1.23 0.00 1.05 0.56 0.86
0.00 0.00 0.15 0.00 0.03
0.00 0.00 0.00 0.00 0.00
0.00 0.00 0.03 0.90 0.00
0.00 0.00 1.10 0.11 0.68
0.07 0.00 0.78 1.28 1.06
0.39 0.46 0.26 0.00 0.00
0.00 0.85 0.00 0.81 0.00
0.04 0.86 0.00 0.00 0.00
0.00 0.00 0.00 1.45 0.00
0.00 0.00 0.15 0.00 0.00
0.50 0.60 0.00 1.33 0.00
1.15 0.00 1.44 0.82 0.00
0.00 0.01 0.65 0.30 0.00
0.03 0.76 1.12 0.00 0.00
0.59 0.00 0.14 1.16 0.75
0.00 0.00 0.00 0.00 0.00
0.00 1.24 0.41 0.54 1.36
0.00 0.06 0.00 0.00 0.00
0.00 0.76 0.18 1.00 0.00
0.00 0.00 0.00 1.08 0.00
0.00 0.34 0.00 0.82 0.00
0.54 0.00 0.55 0.00 0.97
1.29 0.22 0.00 0.07 0.00
1.31 1.43 0.00 0.35 1.37
0.81 0.00 0.25 0.00 0.90
0.57 0.58 0.00 0.47 0.00
0.51 0.00 0.00 0.50 0.00
0.00 0.00 0.00 1.21 0.23
0.00 0.00 0.00 0.11 0.00
1.08 1.04 0.72 0.00 0.00
0.00 0.00 0.15 0.00 0.80
0.00 0.60 0.00 0.00 1.02
0.00 1.27 0.38 0.69 0.00
1.23 0.00 0.68 0.00 0.31
0.00 0.95 0.00 0.09 0.00
0.00 0.28 0.00 0.00 0.45
0.67 0.92 0.53 1.28 0.13
0.00 0.00 1.02 0.51 0.00
0.00 0.18 0.00 0.00 0.00
0.00 0.00 0.31 0.00 0.98
0.00 0.00 0.00 1.15 0.89
0.00 0.00 0.00 0.42 0.00
1.31 1.27 0.00 0.00 0.00
0.00 0.00 1.23 1.13 0.00
1.05 0.00 0.38 0.00 0.00
0.02 0.00 0.14 0.33 0.12
0.00 0.00 0.00 0.00 0.00
0.00 0.00 1.35 0.18 0.03
0.00 0.00 0.44 0.00 0.00
0.00 1.31 0.19 0.78 0.00
1.17 0.03 1.00 1.02 0.72
nrows and ncols are the number of rows/columns
xllcenter and yllcenter are the coordinates of the centre of the square in the bottom left hand corner of the grid
the cell size is the length of one side of a grid square.
I can read the matrix in and choose to print out values according to their position in the matrix but how would I assign coordinates to such a matrix?
Can I then ask matlab to output the appropriate matrix values when I put in coordinates?
Thanks everyone who can offer me advice!
Since you are a beginner with Matlab, I suggest you investigate the menu option File | Import Data and then study the documentation of the uiimport function.
I have lines as this
ATOM 21001 O WAT 345 7.556 35.954 37.464 0.00 0.00
ATOM 21002 H1 WAT 345 7.076 35.701 36.675 0.00 0.00
ATOM 21003 H2 WAT 345 7.155 35.440 38.164 0.00 0.00
TER 0 0 0.000 0.000 0.000 0.00 0.00
ATOM 21004 O WAT 346 1.183 42.629 26.928 0.00 0.00
ATOM 21005 H1 WAT 346 1.412 43.325 26.313 0.00 0.00
ATOM 21006 H2 WAT 346 1.454 41.823 26.490 0.00 0.00
TER 0 0 0.000 0.000 0.000 0.00 0.00
ATOM 21007 O WAT 347 7.166 53.716 22.860 0.00 0.00
ATOM 21008 H1 WAT 347 7.950 54.234 22.675 0.00 0.00
ATOM 21009 H2 WAT 347 6.855 54.045 23.704 0.00 0.00
TER 0 0 0.000 0.000 0.000 0.00 0.00
ATOM 21010 O WAT 348 9.342 45.695 11.193 0.00 0.00
ATOM 21011 H1 WAT 348 8.488 45.846 10.788 0.00 0.00
ATOM 21012 H2 WAT 348 9.973 45.870 10.494 0.00 0.00
TER 0 0 0.000 0.000 0.000 0.00 0.00
ATOM 21013 O WAT 349 18.303 47.277 18.814 0.00 0.00
ATOM 21014 H1 WAT 349 17.411 47.357 18.476 0.00 0.00
ATOM 21015 H2 WAT 349 18.862 47.407 18.047 0.00 0.00
I want to delete all the characters in line contains TER except the TER word.
I have searched Internet for sed command which can do this but i can not find one which matching specific word.
Could anyone help?
You need to use the following:
sed 's/^TER.*$/TER/'