#!/bin/bash TMP="hello" if [ -f test ];then cat test|while read line do { TMP=${TMP}HELLO echo $TMP export EX=$TMP } done fi echo $TMP echo $EX