RSS

[vim] Delete blank lines

Here are two ways to delete the blank lines in a text file opened with vim:

1. Delete all the blank lines with NO white spaces other than new lines:

:g/^$/d

2. Delete the blank lines containing any type of white spaces:

:g/^\s*$/d

BONUS: Remove only multi blank lines (reduce them to a single blank line) and leaving single blank lines intact:

:g/^\_$\n\_^$/d

Reference: Stack Overflow.

 
Leave a comment

Posted by on August 26, 2013 in vim

 

Tags: , , , , , , ,

[shell] Single vs. double pair of brackets in logical expressions: [] VS. [[]]

Contrary to [[[ prevents word splitting of variable values. So, if VAR="var with spaces", you do not need to double quote $VAR in a test - even though using quotes remains a good habit. Also, [[ prevents pathname expansion, so literal strings with wildcards do not try to expand to filenames. Using [[== and != interpret strings to the right as shell glob patterns to be matched against the value to the left, for instance: [[ "value" == val* ]].

Reference: here

 
Leave a comment

Posted by on June 24, 2013 in shell

 

Tags: , , ,

[gnuplot] Label the x-axis using the numbers from two columns as strings

Let’s look at an example data file first:

+2   +2   10.0
+1   +1    9.0
 0    0    7.8
+1   -1   17.0
+2   -2    1.2

We want to plot the numbers in the third column in the y-axis with (+2,+2), (+1,+1), .., (+2,-2) as the corresponding x-values.

There are two aspects to deal with here, namely
(1) to use strings as (x)tic labels —>  xticlabels function can handle that.
(2) to combine two numbers in two different columns into a single string —> sprintf function can handle that.

Here’s what a sample gnuplot command would look like

gnuplot> plot using ($0):3:xticlabels( sprintf("(%+d,%+d)",$1,$2) ) with linespoints

 
Leave a comment

Posted by on March 8, 2013 in plot

 

Tags: , , , , ,

[plot] Contour plots using gnuplot

Following is the script to plot the data in “data.txt” as contours (with color shades):


# Set terminal and output
set terminal postscript enhanced color
set output 'plot.ps'

# Set various features of the plot
set pm3d
unset surface  # don't need surfaces
set view map
set contour
set key outside
set cntrparam cubicspline  # smooth out the lines
set cntrparam levels 50    # sets the num of contour lines
set pm3d interpolate 20,20 # interpolate the color

# Set a nice color palette
set palette model RGB defined ( 0"black", 1"blue", 2"cyan",3"green",4"yellow",\
     5"red",8"purple" )

# Axes
set xlabel 'COC angle (degree)'
set ylabel 'C-H distance (angstrom)'
set format x '%.1f'
set format y '%.1f'
set format z '%.2f'

# Now plot
splot 'data.txt' using 1:2:3 notitle with lines lt 1

Here’s a sample data file “data.txt”: (click to view)

#####################################################
# Listed are the two lowest energies E0 and E1 as
# functions of angle aCOC and distance rCH in the
# following ion
#
#          O-
#         /
#   H - C
#        \
#         O
#
#####################################################
#
#aCOC   rCH     E0(aCOC, rCH)    E1(aCOC, rCH)
#=====  ======  ================ ===============
80	0.75	-187.9181147924	-187.9158295252
80	0.80	-187.9713312339	-187.9661878018
80	0.85	-188.0105136203	-188.0049447368
80	0.90	-188.0373188825	-188.0312605047
80	0.95	-188.0547148942	-188.0481051036
80	1.00	-188.0649656397	-188.0577399331
80	1.05	-188.0698170896	-188.0619080135
80	1.10	-188.0706328906	-188.0619723592
80	1.15	-188.0685050145	-188.0590323048
80	1.20	-188.0644917047	-188.0546633389
80	1.25	-188.0597160477	-188.0490819904
80	1.30	-188.0539382368	-188.0424343828
80	1.35	-188.0474877143	-188.0350887983
80	1.40	-188.0406394801	-188.0273355872
80	1.45	-188.0336082521	-188.0194021043
80	1.50	-188.0265610977	-188.0114609822
80	1.55	-188.0678564251	-188.0143924120
80	1.60	-188.0679692408	-188.0100172712
80	1.65	-188.0687205158	-188.0053470361
80	1.70	-188.0697815991	-188.0005894930
80	1.75	-188.0709581140	-187.9958838707
80	1.80	-188.0721406231	-187.9913185539
80	1.85	-188.0732798876	-187.9869388013
80	1.90	-188.0743498041	-187.9827745072
80	1.95	-188.0753405189	-187.9788418674
80	2.00	-188.0762508640	-187.9751480979
80	2.05	-188.0770838055	-187.9716945532
80	2.10	-188.0778440633	-187.9684785367
80	2.15	-188.0833154714	-187.9688328784
80	2.20	-188.0837635328	-187.9691478323
80	2.25	-188.0841770785	-187.9694389517
80	2.30	-188.0845557718	-187.9697058672
80	2.35	-188.0849001847	-187.9699484088
80	2.40	-188.0852112318	-187.9701669934
80	2.45	-188.0854903646	-187.9703622593
80	2.50	-188.0857391850	-187.9705352665
80	2.55	-188.0859594829	-187.9706872793
80	2.60	-188.0861535155	-187.9708193368
80	2.65	-188.0863231745	-187.9709329469
80	2.70	-188.0864704115	-187.9710295709
80	2.75	-188.0865972395	-187.9711105520
80	2.80	-188.0867050982	-187.9711777035
80	2.85	-188.0867964173	-187.9712317295
80	2.90	-188.0868726204	-187.9712741915
80	2.95	-188.0869352610	-187.9713063715
80	3.00	-188.0869858378	-187.9713294501

90	0.75	-188.0434255816	-187.9643587820
90	0.80	-188.0991892997	-188.0197576293
90	0.85	-188.1386710232	-188.0587850504
90	0.90	-188.1658149131	-188.0853844547
90	0.95	-188.1835938739	-188.1025245567
90	1.00	-188.1942718698	-188.1124675958
90	1.05	-188.1995928411	-188.1169549625
90	1.10	-188.2009126604	-188.1173431584
90	1.15	-188.1992989026	-188.1147044065
90	1.20	-188.1956064229	-188.1099215130
90	1.25	-188.1905094724	-188.1039297113
90	1.30	-188.1847836373	-188.0976492032
90	1.35	-188.1787634542	-188.0906567257
90	1.40	-188.1724264907	-188.0832732115
90	1.45	-188.1659299379	-188.0757178569
90	1.50	-188.1594123325	-188.0681556854
90	1.55	-188.1458496111	-188.1234717482
90	1.60	-188.1424178287	-188.1223132544
90	1.65	-188.1384849755	-188.1221421795
90	1.70	-188.1343179889	-188.1224965523
90	1.75	-188.1300897274	-188.1231025675
90	1.80	-188.1258995372	-188.1238122713
90	1.85	-188.1245444083	-188.1218090783
90	1.90	-188.1252514840	-188.1178619652
90	1.95	-188.1259191266	-188.1140765395
90	2.00	-188.1265393605	-188.1104679625
90	2.05	-188.1271122211	-188.1070438024
90	2.10	-188.1276404365	-188.1038078147
90	2.15	-188.1281275211	-188.1007611090
90	2.20	-188.1285765433	-188.0979031565
90	2.25	-188.1289903757	-188.0952316033
90	2.30	-188.1293707470	-188.0927434297
90	2.35	-188.1297195039	-188.0904339475
90	2.40	-188.1300376170	-188.0882980526
90	2.45	-188.1303271767	-188.0863284777
90	2.50	-188.1305889449	-188.0845184405
90	2.55	-188.1308241022	-188.0828601031
90	2.60	-188.1310338961	-188.0813451010
90	2.65	-188.1312196781	-188.0799646755
90	2.70	-188.1313828162	-188.0787099209
90	2.75	-188.1315247494	-188.0775718734
90	2.80	-188.1316469345	-188.0765416950
90	2.85	-188.1317509048	-188.0756107219
90	2.90	-188.1318381669	-188.0747706533
90	2.95	-188.1319102373	-188.0740135758
90	3.00	-188.1319686139	-188.0733320290

100	0.75	-188.1202728059	-187.9863445113
100	0.80	-188.1763305819	-188.0419856076
100	0.85	-188.2161205896	-188.0812750106
100	0.90	-188.2435956713	-188.1081577022
100	0.95	-188.2617335603	-188.1256064922
100	1.00	-188.2728029064	-188.1358864347
100	1.05	-188.2785495178	-188.1407422714
100	1.10	-188.2803294806	-188.1415320758
100	1.15	-188.2792056321	-188.1393277513
100	1.20	-188.2760202942	-188.1349990427
100	1.25	-188.2714452937	-188.1293181766
100	1.30	-188.2659990230	-188.1231309386
100	1.35	-188.2602474471	-188.1165563287
100	1.40	-188.2542791597	-188.1096115083
100	1.45	-188.2481741622	-188.1024984541
100	1.50	-188.2420420775	-188.0953740838
100	1.55	-188.2359750418	-188.0883541959
100	1.60	-188.2233575715	-188.1439954492
100	1.65	-188.2201072402	-188.1427924962
100	1.70	-188.2164692887	-188.1423772053
100	1.75	-188.2126458384	-188.1423899705
100	1.80	-188.2087737520	-188.1426106726
100	1.85	-188.2049310937	-188.1429210972
100	1.90	-188.2011678817	-188.1432561343
100	1.95	-188.1975152001	-188.1435838167
100	2.00	-188.1939914120	-188.1438923023
100	2.05	-188.1906084723	-188.1441792127
100	2.10	-188.1873743346	-188.1444464573
100	2.15	-188.1842942309	-188.1446973480
100	2.20	-188.1813717872	-188.1449347003
100	2.25	-188.1786091332	-188.1451604925
100	2.30	-188.1760074461	-188.1453754116
100	2.35	-188.1735666619	-188.1455793814
100	2.40	-188.1712845313	-188.1457728004
100	2.45	-188.1691587167	-188.1459547176
100	2.50	-188.1671853861	-188.1461244992
100	2.55	-188.1653597088	-188.1462815598
100	2.60	-188.1636760024	-188.1464254231
100	2.65	-188.1621281329	-188.1465555136
100	2.70	-188.1607082884	-188.1466725722
100	2.75	-188.1594095907	-188.1467762007
100	2.80	-188.1582241248	-188.1468669953
100	2.85	-188.1571448683	-188.1469447423
100	2.90	-188.1561635352	-188.1470106993
100	2.95	-188.1552728989	-188.1470653453
100	3.00	-188.1544657146	-188.1471095265

110	0.75	-188.1641925299	-187.9895948728
110	0.80	-188.2205702549	-188.0455015853
110	0.85	-188.2606935389	-188.0850831049
110	0.90	-188.2885229152	-188.1122880508
110	0.95	-188.3070430454	-188.1300934390
110	1.00	-188.3185274081	-188.1407699899
110	1.05	-188.3247262071	-188.1460670243
110	1.10	-188.3269972945	-188.1473475861
110	1.15	-188.3264026375	-188.1456877945
110	1.20	-188.3237784372	-188.1419595041
110	1.25	-188.3197825604	-188.1369152665
110	1.30	-188.3149221228	-188.1312429979
110	1.35	-188.3096421413	-188.1251790471
110	1.40	-188.3041226977	-188.1187740318
110	1.45	-188.2984538596	-188.1122002090
110	1.50	-188.2927369087	-188.1056027428
110	1.55	-188.2870576341	-188.0990891227
110	1.60	-188.2717795687	-188.1472693351
110	1.65	-188.2693194805	-188.1448151956
110	1.70	-188.2662749952	-188.1435058404
110	1.75	-188.2629011976	-188.1428526989
110	1.80	-188.2593762827	-188.1425457623
110	1.85	-188.2558049007	-188.1424097388
110	1.90	-188.2522535479	-188.1423445712
110	1.95	-188.2487647072	-188.1422970001
110	2.00	-188.2453610125	-188.1422474515
110	2.05	-188.2420591467	-188.1421901489
110	2.10	-188.2388674089	-188.1421310584
110	2.15	-188.2357931166	-188.1420772784
110	2.20	-188.2328420046	-188.1420354905
110	2.25	-188.2300193460	-188.1420097804
110	2.30	-188.2273298036	-188.1420015574
110	2.35	-188.2247776130	-188.1420096428
110	2.40	-188.2223654567	-188.1420318697
110	2.45	-188.2200938708	-188.1420661760
110	2.50	-188.2179631002	-188.1421091745
110	2.55	-188.2159714643	-188.1421581462
110	2.60	-188.2141170446	-188.1422096351
110	2.65	-188.2123947280	-188.1422626487
110	2.70	-188.2108004950	-188.1423145645
110	2.75	-188.2093289163	-188.1423638220
110	2.80	-188.2079740477	-188.1424091881
110	2.85	-188.2067294905	-188.1424498395
110	2.90	-188.2055887773	-188.1424850987
110	2.95	-188.2045452455	-188.1425146607
110	3.00	-188.2035922742	-188.1425384325

120	0.75	-188.1855291882	-187.9801622330
120	0.80	-188.2422586778	-188.0363755341
120	0.85	-188.2827544313	-188.0763020615
120	0.90	-188.3109837180	-188.1038946956
120	0.95	-188.3299374633	-188.1221354685
120	1.00	-188.3418949630	-188.1333004505
120	1.05	-188.3486103186	-188.1391454044
120	1.10	-188.3514444765	-188.1410390792
120	1.15	-188.3514591011	-188.1400641841
120	1.20	-188.3494859725	-188.1370970178
120	1.25	-188.3461702408	-188.1328768553
120	1.30	-188.3420090310	-188.1279735639
120	1.35	-188.3373712292	-188.1225968177
120	1.40	-188.3324301584	-188.1168773158
120	1.45	-188.3273039658	-188.1109793151
120	1.50	-188.3220976249	-188.1050388343
120	1.55	-188.3168963549	-188.0991553552
120	1.60	-188.3117616284	-188.0934007898
120	1.65	-188.2970845363	-188.1352604340
120	1.70	-188.2947896618	-188.1329179947
120	1.75	-188.2919830439	-188.1315521151
120	1.80	-188.2888883936	-188.1307377490
120	1.85	-188.2856526104	-188.1302111106
120	1.90	-188.2823666667	-188.1298154860
120	1.95	-188.2790885993	-188.1294586332
120	2.00	-188.2758596842	-188.1290854726
120	2.05	-188.2727031851	-188.1286733909
120	2.10	-188.2696338592	-188.1282197680
120	2.15	-188.2666567895	-188.1277412526
120	2.20	-188.2637700156	-188.1272678182
120	2.25	-188.2609700494	-188.1268311768
120	2.30	-188.2582583642	-188.1264520746
120	2.35	-188.2556422190	-188.1261369287
120	2.40	-188.2531313984	-188.1258821124
120	2.45	-188.2507331853	-188.1256812720
120	2.50	-188.2484546852	-188.1255249060
120	2.55	-188.2462984828	-188.1254060281
120	2.60	-188.2442670765	-188.1253164920
120	2.65	-188.2423592736	-188.1252510756
120	2.70	-188.2405750645	-188.1252028847
120	2.75	-188.2389096755	-188.1251695068
120	2.80	-188.2373604695	-188.1251462403
120	2.85	-188.2359227716	-188.1251303944
120	2.90	-188.2345920511	-188.1251191983
120	2.95	-188.2333629653	-188.1251108382
120	3.00	-188.2322299671	-188.1251039137

130	0.75	-188.1604996514	-188.0470870334
130	0.80	-188.2170103071	-188.1070972457
130	0.85	-188.2577608949	-188.1470932635
130	0.90	-188.2862052633	-188.1745478662
130	0.95	-188.3053298962	-188.1924357949
130	1.00	-188.3174108188	-188.2030154592
130	1.05	-188.3241971058	-188.2080159207
130	1.10	-188.3270414181	-188.2087683583
130	1.15	-188.3269950523	-188.2063001114
130	1.20	-188.3248755142	-188.2014069847
130	1.25	-188.3213244148	-188.1947019209
130	1.30	-188.3168498806	-188.1866562207
130	1.35	-188.3119057842	-188.1775945871
130	1.40	-188.3080544335	-188.1667202783
130	1.45	-188.3093401977	-188.1527597572
130	1.50	-188.3084856956	-188.1422292287
130	1.55	-188.3089123796	-188.1321471722
130	1.60	-188.3096728211	-188.1237044703
130	1.65	-188.3095544393	-188.1178484462
130	1.70	-188.3083310259	-188.1142634985
130	1.75	-188.3063076680	-188.1121846037
130	1.80	-188.3040523057	-188.1111785882
130	1.85	-188.3012008829	-188.1106693696
130	1.90	-188.2982116972	-188.1104757126
130	1.95	-188.2951511028	-188.1105089854
130	2.00	-188.2920641368	-188.1107414663
130	2.05	-188.2890035552	-188.1111596395
130	2.10	-188.2860392169	-188.1117267142
130	2.15	-188.2832348133	-188.1123097113
130	2.20	-188.2805667701	-188.1128878564
130	2.25	-188.2768080353	-188.1299317844
130	2.30	-188.2741213257	-188.1342750717
130	2.35	-188.2715156841	-188.1383831613
130	2.40	-188.2689900027	-188.1422579907
130	2.45	-188.2665437077	-188.1459045042
130	2.50	-188.2641761645	-188.1493301178
130	2.55	-188.2618864336	-188.1525440880
130	2.60	-188.2596734406	-188.1555566802
130	2.65	-188.2575359622	-188.1583786922
130	2.70	-188.2554726345	-188.1610210877
130	2.75	-188.2534819505	-188.1634947518
130	2.80	-188.2515622892	-188.1658102970
130	2.85	-188.2497120325	-188.1679778452
130	2.90	-188.2479293712	-188.1700071690
130	2.95	-188.2462126161	-188.1719073592
130	3.00	-188.2445599380	-188.1736870874

140	0.75	-188.1511562442	-188.0447139466
140	0.80	-188.2086864436	-188.1017811853
140	0.85	-188.2499972563	-188.1423512115
140	0.90	-188.2790574210	-188.1703778193
140	0.95	-188.2988570796	-188.1888397662
140	1.00	-188.3116715996	-188.2000041429
140	1.05	-188.3192429325	-188.2056138825
140	1.10	-188.3229116751	-188.2070166252
140	1.15	-188.3237099929	-188.2052605361
140	1.20	-188.3224308084	-188.2011648180
140	1.25	-188.3196810147	-188.1953727905
140	1.30	-188.3159204945	-188.1883949116
140	1.35	-188.3114943328	-188.1806406309
140	1.40	-188.3066578164	-188.1724429930
140	1.45	-188.3015973189	-188.1640756966
140	1.50	-188.2964443835	-188.1557673401
140	1.55	-188.2912941685	-188.1477037459
140	1.60	-188.2862192422	-188.1400295555
140	1.65	-188.2812860917	-188.1328446277
140	1.70	-188.2824524568	-188.1590086362
140	1.75	-188.2791586009	-188.1572994152
140	1.80	-188.2760217977	-188.1559590050
140	1.85	-188.2730381635	-188.1549490956
140	1.90	-188.2702004622	-188.1542321480
140	1.95	-188.2674980412	-188.1537752089
140	2.00	-188.2649187694	-188.1535507640
140	2.05	-188.2624546304	-188.1535337214
140	2.10	-188.2601024129	-188.1537007701
140	2.15	-188.2578612503	-188.1540298495
140	2.20	-188.2557333442	-188.1544981670
140	2.25	-188.2537247121	-188.1550803436
140	2.30	-188.2518447907	-188.1557481925
140	2.35	-188.2500986188	-188.1564782749
140	2.40	-188.2484931988	-188.1572456836
140	2.45	-188.2470320003	-188.1580296284
140	2.50	-188.2457125939	-188.1588158597
140	2.55	-188.2445298982	-188.1595934339
140	2.60	-188.2434775133	-188.1603533399
140	2.65	-188.2425382322	-188.1610979599
140	2.70	-188.2416972100	-188.1618279339
140	2.75	-188.2409449770	-188.1625392275
140	2.80	-188.2402641281	-188.1632365542
140	2.85	-188.2396407092	-188.1639221303
140	2.90	-188.2390618134	-188.1645982045
140	2.95	-188.2385175605	-188.1652651939
140	3.00	-188.2379987930	-188.1659240027

150	0.75	-188.1285174626	-188.0343050434
150	0.80	-188.1865306466	-188.0918018209
150	0.85	-188.2284124793	-188.1328118296
150	0.90	-188.2581332977	-188.1612919455
150	0.95	-188.2786830569	-188.1802249037
150	1.00	-188.2923323544	-188.1918850062
150	1.05	-188.3008169318	-188.1980220637
150	1.10	-188.3054674907	-188.1999926605
150	1.15	-188.3073041713	-188.1988544702
150	1.20	-188.3071079315	-188.1954349357
150	1.25	-188.3054668868	-188.1903912778
150	1.30	-188.3028273998	-188.1842416511
150	1.35	-188.2995202943	-188.1774025289
150	1.40	-188.2957882289	-188.1702102383
150	1.45	-188.2918069385	-188.1629363621
150	1.50	-188.2877027866	-188.1557973523
150	1.55	-188.2835663497	-188.1489606909
150	1.60	-188.2794721164	-188.1425405718
150	1.65	-188.2754816038	-188.1366083542
150	1.70	-188.2716774858	-188.1311736329
150	1.75	-188.2681722646	-188.1261974286
150	1.80	-188.2654318094	-188.1213267617
150	1.85	-188.3033272432	-188.1005275966
150	1.90	-188.3016329162	-188.1054150957
150	1.95	-188.2998130815	-188.1104293707
150	2.00	-188.2979333896	-188.1154142060
150	2.05	-188.2960298985	-188.1202775526
150	2.10	-188.2941285950	-188.1249600622
150	2.15	-188.2922439165	-188.1294291314
150	2.20	-188.2903866000	-188.1336662638
150	2.25	-188.2885640708	-188.1376634032
150	2.30	-188.2867816022	-188.1414195085
150	2.35	-188.2850427690	-188.1449385085
150	2.40	-188.2833503526	-188.1482272681
150	2.45	-188.2817059558	-188.1512951551
150	2.50	-188.2801108174	-188.1541526321
150	2.55	-188.2785656234	-188.1568110035
150	2.60	-188.2770706557	-188.1592819404
150	2.65	-188.2756260391	-188.1615769916
150	2.70	-188.2742315784	-188.1637075752
150	2.75	-188.2728869261	-188.1656846858
150	2.80	-188.2715915889	-188.1675188143
150	2.85	-188.2703448449	-188.1692199941
150	2.90	-188.2691460401	-188.1707974844
150	2.95	-188.2679943287	-188.1722600445
150	3.00	-188.2668887879	-188.1736158390

170	0.75	-188.0476590242	-187.9885873174
170	0.80	-188.1067544994	-188.0465603337
170	0.85	-188.1501016070	-188.0881112947
170	0.90	-188.1816429496	-188.1172227523
170	0.95	-188.2043334847	-188.1369057954
170	1.00	-188.2204068223	-188.1494619594
170	1.05	-188.2315448183	-188.1566823367
170	1.10	-188.2390506996	-188.1599352609
170	1.15	-188.2438924552	-188.1603109764
170	1.20	-188.2468142558	-188.1586498764
170	1.25	-188.2483711971	-188.1556134511
170	1.30	-188.2489755027	-188.1517194055
170	1.35	-188.2489291064	-188.1473716959
170	1.40	-188.2484495605	-188.1428824025
170	1.45	-188.2476919113	-188.1384860028
170	1.50	-188.2467669529	-188.1343487047
170	1.55	-188.2457532912	-188.1305782460
170	1.60	-188.2447088683	-188.1272308504
170	1.65	-188.2436793683	-188.1243193560
170	1.70	-188.2426997413	-188.1218266252
170	1.75	-188.2418198705	-188.1196943271
170	1.80	-188.2411431654	-188.1177998255
170	1.85	-188.2780020991	-188.0956617124
170	1.90	-188.2788644426	-188.0974991406
170	1.95	-188.2794311717	-188.0996501617
170	2.00	-188.2797606636	-188.1019868714
170	2.05	-188.2799083776	-188.1044038101
170	2.10	-188.2799153507	-188.1068265957
170	2.15	-188.2798121854	-188.1092042856
170	2.20	-188.2796218561	-188.1115034332
170	2.25	-188.2793627830	-188.1137022807
170	2.30	-188.2790477348	-188.1157897740
170	2.35	-188.2786879500	-188.1177598026
170	2.40	-188.2782929706	-188.1196101828
170	2.45	-188.2778679566	-188.1213444865
170	2.50	-188.2774194800	-188.1229656036
170	2.55	-188.2769523394	-188.1244785051
170	2.60	-188.2764718933	-188.1258875970
170	2.65	-188.2759789553	-188.1272016307
170	2.70	-188.2754778321	-188.1284255073
170	2.75	-188.2749711671	-188.1295653588
170	2.80	-188.2744615361	-188.1306268954
170	2.85	-188.2739509518	-188.1316158762
170	2.90	-188.2734430724	-188.1325358760
170	2.95	-188.2729362490	-188.1333952543
170	3.00	-188.2724335635	-188.1341971193

190	0.75	-187.9349407041	-187.9049991438
190	0.80	-187.9963004052	-187.9600178760
190	0.85	-188.0422027439	-187.9993225884
190	0.90	-188.0765894171	-188.0269522975
190	0.95	-188.1024716743	-188.0459407658
190	1.00	-188.1222012013	-188.0586017954
190	1.05	-188.1378122608	-188.0666713573
190	1.10	-188.1525488763	-188.0715816898
190	1.15	-188.1635819676	-188.0786822516
190	1.20	-188.1726065738	-188.0855182466
190	1.25	-188.1804218618	-188.0918102088
190	1.30	-188.1874311952	-188.0975794728
190	1.35	-188.1939217350	-188.1027972590
190	1.40	-188.1999868439	-188.1075201557
190	1.45	-188.2057147235	-188.1117512372
190	1.50	-188.2111296906	-188.1155271830
190	1.55	-188.2162385282	-188.1188866436
190	1.60	-188.2210331267	-188.1218753486
190	1.65	-188.2255140905	-188.1245266065
190	1.70	-188.2296791203	-188.1268751597
190	1.75	-188.2335208749	-188.1289604803
190	1.80	-188.2370445753	-188.1308096798
190	1.85	-188.2402561032	-188.1324496689
190	1.90	-188.2431649765	-188.1339041817
190	1.95	-188.2457838916	-188.1351940934
190	2.00	-188.2481280355	-188.1363378460
190	2.05	-188.2502144628	-188.1373517389
190	2.10	-188.2520617947	-188.1382498534
190	2.15	-188.2536874651	-188.1390464308
190	2.20	-188.2551112578	-188.1397519986
190	2.25	-188.2563509019	-188.1403774836
190	2.30	-188.2574237585	-188.1409323366
190	2.35	-188.2583462499	-188.1414249655
190	2.40	-188.2591336858	-188.1418628481
190	2.45	-188.2598006700	-188.1422521392
190	2.50	-188.2603594469	-188.1425993956
190	2.55	-188.2608221635	-188.1429093994
190	2.60	-188.2612001868	-188.1431859732
190	2.65	-188.2615027992	-188.1434334339
190	2.70	-188.2617390687	-188.1436548654
190	2.75	-188.2619170705	-188.1438530591
190	2.80	-188.2620440719	-188.1440304658
190	2.85	-188.2621266496	-188.1441892056
190	2.90	-188.2621705266	-188.1443313573
190	2.95	-188.2621809693	-188.1444586346
190	3.00	-188.2621627843	-188.1445725082

200	0.75	-187.8922526924	-187.8477450345
200	0.80	-187.9531144034	-187.9020684311
200	0.85	-188.0004855149	-187.9530803819
200	0.90	-188.0333150462	-187.9928302710
200	0.95	-188.0572893280	-188.0225049473
200	1.00	-188.0746438987	-188.0436432931
200	1.05	-188.0872585533	-188.0577478708
200	1.10	-188.1031741381	-188.0668500693
200	1.15	-188.1178518191	-188.0731687925
200	1.20	-188.1312002902	-188.0786833670
200	1.25	-188.1432181172	-188.0842660162
200	1.30	-188.1541740341	-188.0899201317
200	1.35	-188.1642920559	-188.0954974982
200	1.40	-188.1736906597	-188.1008943317
200	1.45	-188.1824249254	-188.1060520919
200	1.50	-188.1905181638	-188.1109432549
200	1.55	-188.1979816911	-188.1155587163
200	1.60	-188.2048308586	-188.1198940691
200	1.65	-188.2110810824	-188.1239537401
200	1.70	-188.2167502318	-188.1277476265
200	1.75	-188.2218672499	-188.1312810811
200	1.80	-188.2264618047	-188.1345638261
200	1.85	-188.2305662623	-188.1376065810
200	1.90	-188.2342148706	-188.1404206128
200	1.95	-188.2374426794	-188.1430176890
200	2.00	-188.2402848246	-188.1454098003
200	2.05	-188.2427756794	-188.1476091796
200	2.10	-188.2449484003	-188.1496280544
200	2.15	-188.2468352031	-188.1514778209
200	2.20	-188.2484640221	-188.1531720039
200	2.25	-188.2498629215	-188.1547215389
200	2.30	-188.2510571154	-188.1561376131
200	2.35	-188.2520695758	-188.1574309918
200	2.40	-188.2529212027	-188.1586118522
200	2.45	-188.2536312018	-188.1596894551
200	2.50	-188.2542161383	-188.1606732032
200	2.55	-188.2546915889	-188.1615710983
200	2.60	-188.2550714001	-188.1623906276
200	2.65	-188.2553678815	-188.1631387191
200	2.70	-188.2555920923	-188.1638216086
200	2.75	-188.2557538615	-188.1644449889
200	2.80	-188.2558618032	-188.1650141335
200	2.85	-188.2559238140	-188.1655335603
200	2.90	-188.2559466235	-188.1660076341
200	2.95	-188.2559362016	-188.1664402790
200	3.00	-188.2558978269	-188.1668350544

And here’s the actual plot:
plot

 
4 Comments

Posted by on January 19, 2013 in plot

 

Tags: , , ,

[sed] Delete the lines lying in between two patterns

Let’s take an plain text file, input.txt, that looks like this

PATTERN-1
First line of unimportant text
Second line of unimportant text
PATTERN-2
Some more texts (may/ mayn't be important!)

We want to delete some of the lines from the file using the command line stream editor, sed.

1. Use the following command to delete the lines lying between PATTERN-1 and PATTERN-2 , excluding the lines containing these patterns:
sed '/PATTERN-1/,/PATTERN-2/{//!d}' input.txt

If you want to modify the file itself, instead of just the file stream, include the “-i” flag after sed.

2. Use the following command to delete the lines lying between PATTERN-1 and PATTERN-2 , including the lines containing these patterns:
sed '/PATTERN-1/,/PATTERN-2/d' input.txt

3. To delete all the lines after PATTERN-2, use this
sed '/PATTERN-1/,$d' input.txt

4. To delete lines, say 2 through 4 (if you know the correct line numbers, of course!), use this

sed '2,4d' input.txt

Here is a good sed reference.

 
Leave a comment

Posted by on January 9, 2013 in sed

 

Tags: , , , , , , , ,

[sed] Print all the lines in between two patterns

The following CLI one-liner prints all the lines between the lines containing PATTERN1 and PATTERN2 (including the lines with these two patterns) in a file, FILENAME:

sed -n '/PATTERN1/,/PATTERN2/p' FILENAME
 
2 Comments

Posted by on December 17, 2012 in cli, sed

 

Tags: , , , , , ,

[unix] Send mail from the command line using mail and sendmail commands

1. If the message isn’t too long then type the following in the commandline and hit enter

$ mail -s "Subject of the email" -c cc_recipient@domain1.com -b bcc_recipient@domain2.com main_recipient@domain3.com -- -F"Sender Name" -fSender@domain4.com

Then keep typing your message. To send it either enter a blank line with just a single period (“ . ”’) in it and hit enter again, or just hit control+d. That’s it! A email to main_recipient@domain3.com has been sent with a carbon copy (cc) to cc_recipient@domain1.com and a blind carbon copy (bcc) to bcc_recipient@domain2.com. The recipients will see the message from “Sender Name” who has email address Sender@domain4.com.

The sendmail flags (-f and -F) come after the -- sign. Notice that there is no space between the sendmail flags and the corresponding arguments.

Needless to say, you may skip the cc and bcc fields.

2. If the message is fairly long you may want to compose it in a text file, say message.txt, using a convenient editor. Send the email with the body of the email as the text in message.txt as follows

$ mail -s "Subject of the email" -c cc_recipient@domain1.com -b bcc_recipient@domain2.com main_recipient@domain3.com -- -F"Sender Name" -f sender@domain4.com < message.txt

3. In order to send a file as attachement (say, attachment.pdf) use the following

$ uuencode attachment.pdf  attachment_name_that_the_reciepents_will_see.pdf | mail -s "Subject of the email" -c cc_recipient@domain1.com -b bcc_recipient@domain2.com main_recipient@domain3.com -- -F"Sender Name" -f sender@domain4.com < message.txt

Update: If -F and -f flags are used together only -f and its argument are used. Weird!

 
Leave a comment

Posted by on November 12, 2012 in linux, unix

 

Tags: ,

 
Follow

Get every new post delivered to your Inbox.

Join 29 other followers

%d bloggers like this: