Saturday, March 21, 2015

UNIX : Solution of a contest


#!/bin/bash

i=0
j=0

while read LINE
do
echo "$LINE" | egrep "a|A" > /dev/null 2>&1
if [ "$?" -ne "0" ]; then
UNIX[$j]=$LINE
j=`expr $j + 1`
fi
i=`expr $i + 1`
done

echo ${UNIX[@]}


#!/bin/bash

i=0
j=0

while read LINE
do
if [ $i -gt 2 ] && [ $i -lt 8 ]; then
UNIX[$j]=$LINE
j=`expr $j + 1`
fi
i=`expr $i + 1`
done


echo ${UNIX[@]}



#!/bin/bash

i=0

while read LINE
do
UNIX[i]=$LINE
i=`expr $i + 1`
done

echo "${UNIX[@]} ${UNIX[@]} ${UNIX[@]}"



#!/bin/bash

i=0

while read LINE
do
echo "$LINE" | cut -c1 | grep "[A-Z]" > /dev/null 2>&1
if [ "$?" -eq "0" ]; then
UNIX[$i]=`echo $LINE | sed 's/[A-Z]/./'`
else
UNIX[$i]=$LINE
fi
i=`expr $i + 1`
done

echo "${UNIX[@]}"

No comments:

Post a Comment