1

ここでは、最初と 2 番目の wt^ を対応する s^ とともに出力ファイルに出力しようとしています。残りの wt^ と p^ は別の出力ファイルに出力する必要があります。これどうやってするの?

入力ファイルはこのようになります

 wt^RHEL System Overview(contd..) 
            s^Supported architectures include:
            s^32-bit x86 compatible systems
            s^64-bit AMD64 (Opteron) and Intel EM64T systems


    wt^RHEL System Overview(contd..)        
                s^Common deployments        
                s^High volume deployments include:
                s^Corporate applications (CRM, ERP, etc.)
                s^Databases

    wt^RHEL System Overview(contd..)
            s^Network infrastructure systems
            s^Web serving
            s^File/print serving
            s^HPC compute systems   

出力ファイルは次のようになります

output1.txt:

wt^RHEL System Overview(contd..) 
                s^Supported architectures include:
                s^32-bit x86 compatible systems
                s^64-bit AMD64 (Opteron) and Intel EM64T systems


        wt^RHEL System Overview(contd..)        
                    s^Common deployments        
                    s^High volume deployments include:
                    s^Corporate applications (CRM, ERP, etc.)
                    s^Databases

output2.txt:

wt^RHEL System Overview(contd..)
                s^Network infrastructure systems
                s^Web serving
                s^File/print serving
                s^HPC compute systems   

私が試してみました

count=$(cat $( ls unit-*-slides.txt | sort -n ) | grep -E "[ ]*(st\^|p\^)" >> output.txt)

しかし、これはすべてのものを印刷しています。

4

1 に答える 1