■スペース
awk '{print $1,$2,$3}' ファイル名
# echo "I have a Pen , an Apple and Pineapple " | awk '{print $4}'
Pen
# echo "I have a Pen , an Apple and Pineapple " | awk '{print $7 " " $9}'
Apple Pineapple
■区切り文字指定
# echo "I have a Pen, /an Apple /a Pineapple " | awk -F , '{print $2}'
/an Apple /a Pineapple
# echo "I have a Pen, /an Apple /a Pineapple " | awk -F / '{print $3}'
a Pineapple
# echo "I have a Pen, /an Apple /a Pineapple " | awk -F an '{print $2}'
Apple /a Pineapple
■まとめ PPAP
# APEN=$(echo "I have a Pen. I have an Apple." | awk '{print $8 $4 "!"}')
# echo "Uhnn" $APEN
Uhnn Apple.Pen.!
# PPEN=$(echo "I have a Pen. I have a Pineapple." | awk '{print $8 $4 "!"}')
# echo "Uhnn" $PPEN
Uhnn Pineapple.Pen.!
# echo $APEN $PPEN
Apple.Pen.! Pineapple.Pen.!
# echo "I have a Pen. I have a Pineapple. I have an Apple." | awk '{print "Uhnn" " " $4 $8 $12 $4 "!"}'
Uhnn Pen.Pineapple.Apple.Pen.!
Thanks for
http://www.ksknet.net/linuxai/awk.html
0 件のコメント:
コメントを投稿