How do I best pass arguments to a Perl one-liner?

前端 未结 7 1757
误落风尘
误落风尘 2020-12-05 05:27

I have a file, someFile, like this:

$cat someFile
hdisk1 active
hdisk2 active

I use this shell script to check:



        
7条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-05 05:46

    Sometimes breaking the Perl enclosure is a good trick for these one-liners:

    for d in 1 2 ; do cat kk2 | perl -lne ' print "'"${d}"': OK" if /hdisk'"${d}"'\s+/';done
    

提交回复
热议问题