Hi,
I'm new to Unix. I want to read the all the lines from a text file and write the alternate lines into another file. Please give me a shell script solution.
file1
-----
one
two
three
four
five
six
seven
newfile(it should contain the alternate lines from the file1)
-------
one
three
five
seven
rm -f fileout
i=1
while read line
do
if [[ $i -eq 1 ]]
then
echo $line >>fileout
i=0
continue
fi
if [[ $i -eq 0 ]]
then
i=$((i+1))
continue
fi
done<$filename