#!bin/bash
# 分隔符
soh=`echo 1 | awk '{printf("%c", $1)}'`
# sed -i -e 's/|/'$soh'/g' $1
for readFile in `cat $1`;
do
echo $readFile|awk -F "$soh" '{for(i=1;i<=NF;i++){print i,"= " $i}}'
echo "--------------------------"
done
以下按照条件来显示
echo "dd|vbfg|wcx|wdwf|dfd"|awk -F '|' '{for(i=1;i<=NF;i++){ if ( i < 3 ) { print i " = " $i } continue }}'
或写成以下的格式:
#!bin/sh
a="one,two,three,four"
b=`echo $a |awk -F ',' '{for(i=1;i<=NF;i++){print $i}}'`
for s in $b
do
echo "----"$b
echo $s
done