2015年5月13日 星期三

The note for Linux shell

1. Iterate the member in the array
declare -a array

for i in "${arrar[@]}"
do
    echo $i
done



2. Read file
while read line
do
   echo $line
done < xxx.file

3. use the variable in the awk and output the hex string to binary file
for (( index=0; index<256 index="index+4))</p">do
    data=0x`cat "a.log" | awk '{printf $'$((index+1))' $'$((index+2))' $'$((index+3))' $'$((index+4))'}'
    printf "0x0: %.8x" $data | xxd -r -g0 >> a.bin
done

4. use the separator ":" in the awk

cat a.log | awk 'BEGIN {FS=":"} {printf $1 $2 $3}'

沒有留言: