vortex5566的个人博客分享 http://blog.sciencenet.cn/u/vortex5566

博文

利用cat 在shell脚本中写参数文件

已有 4405 次阅读 2014-3-21 14:38 |个人分类:科研|系统分类:科研笔记| cat


文中cat部分实现了xmgrace的参数文件的制作,xmgrace的参数文件实现了对输入文件做直方图


#!/bin/sh


rm *log

for ((i=1;i<51;i=i+1));

do

number=`wc -l ''''$i'''_dis.datz'`

echo $number

var=`echo $number | awk -F ' ' '{print $1}'`

echo $var

ave=`expr $var / 7`


       awk '{if ($1<'''$ave''') print $2 }' ${i}_dis.datz > ${i}_1st.log

       awk '{if ($1>'''$ave''' && $1< 2*'''$ave''') print $2 }' ${i}_dis.datz > ${i}_2nd.log

       awk '{if ($1>2*'''$ave''' && $1< 3*'''$ave''') print $2 }' ${i}_dis.datz > ${i}_3rd.log

       awk '{if ($1>3*'''$ave''' && $1< 4*'''$ave''') print $2 }' ${i}_dis.datz > ${i}_4th.log

       awk '{if ($1>4*'''$ave''' && $1< 5*'''$ave''') print $2 }' ${i}_dis.datz > ${i}_5th.log

       awk '{if ($1>5*'''$ave''' && $1< 6*'''$ave''') print $2 }' ${i}_dis.datz > ${i}_6th.log

       awk '{if ($1>6*'''$ave''') print $2 }' ${i}_dis.datz > ${i}_7th.log


cat >bfile.hy <<EOF

arrange (1,1,.1,.6,.6,ON,ON,ON)

FOCUS G0

READ BAR "${i}_1st.log"

READ BAR "${i}_2nd.log"

READ BAR "${i}_3rd.log"

READ BAR "${i}_4th.log"

READ BAR "${i}_5th.log"

READ BAR "${i}_6th.log"

READ BAR "${i}_7th.log"

HISTOGRAM (S0, MESH(0, 15, 101), OFF, ON)

HISTOGRAM (S1, MESH(0, 15, 101), OFF, ON)

HISTOGRAM (S2, MESH(0, 15, 101), OFF, ON)

HISTOGRAM (S3, MESH(0, 15, 101), OFF, ON)

HISTOGRAM (S4, MESH(0, 15, 101), OFF, ON)

HISTOGRAM (S5, MESH(0, 15, 101), OFF, ON)

HISTOGRAM (S6, MESH(0, 15, 101), OFF, ON)

WRITE G0.S7 FILE "${i}_temp1.datx"

WRITE G0.S8 FILE "${i}_temp2.datx"

WRITE G0.S9 FILE "${i}_temp3.datx"

WRITE G0.S10 FILE "${i}_temp4.datx"

WRITE G0.S11 FILE "${i}_temp5.datx"

WRITE G0.S12 FILE "${i}_temp6.datx"

WRITE G0.S13 FILE "${i}_temp7.datx"

# clear all data from program

KILL G0.S0

KILL G0.S1

KILL G0.S3

KILL G0.S4

KILL G0.S5

KILL G0.S6

KILL G0.S7

KILL G0.S8

KILL G0.S9

KILL G0.S10

KILL G0.S11

KILL G0.S12

KILL G0.S13

# reread data back in to get rid of formatting

READ NXY "${i}_temp1.datx"

READ NXY "${i}_temp2.datx"

READ NXY "${i}_temp3.datx"

READ NXY "${i}_temp4.datx"

READ NXY "${i}_temp5.datx"

READ NXY "${i}_temp6.datx"

READ NXY "${i}_temp7.datx"

           S0  line color 1

           S1  line color 2

           S2  line color 3

           S3  line color 4

           S4  line color 5

           S5  line color 6

           S6  line color 7


AUTOSCALE                                    

PRINT TO "${i}_output.jpg"

HARDCOPY DEVICE "JPEG"

KILL G0.S3

KILL G0.S4

KILL G0.S5

KILL G0.S6

KILL G0.S7

KILL G0.S8

KILL G0.S9

KILL G0.S10

KILL G0.S11

KILL G0.S12

KILL G0.S13

# reread data back in to get rid of formatting

 READ NXY "${i}_temp1.datx"

READ NXY "${i}_temp2.datx"

READ NXY "${i}_temp3.datx"

READ NXY "${i}_temp4.datx"

READ NXY "${i}_temp5.datx"

READ NXY "${i}_temp6.datx"

READ NXY "${i}_temp7.datx"

                S0  line color 1

                  S1  line color 2

                 S2  line color 3

                 S3  line color 4

                 S4  line color 5

                 S5  line color 6

                 S6  line color 7


                 AUTOSCALE

                                         



PRINT TO "${i}_output.jpg"


HARDCOPY DEVICE "JPEG"

PAGE SIZE 1280, 1024


DEVICE "JPEG" FONT ANTIALIASING on


DEVICE "JPEG" OP "quality:100"


PRINT

EXIT

EOF

xmgrace -batch bfile.hy -nosafe -hardcopy

done





https://wap.sciencenet.cn/blog-459206-777973.html

上一篇:xmgrace batch mode 实现散点图输出
收藏 IP: 211.86.157.*| 热度|

0

该博文允许注册用户评论 请点击登录 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2022-8-19 19:50

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部