Can any one help me to add 2 lines into a file when bash shell script is executed. when we run the same script next time, it should not add same lines into the file from next time onwards.
Asked
Active
Viewed 74 times
0
-
give input example pls. – Kent Mar 12 '14 at 12:20
1 Answers
0
To add lines in a file you can use echo statements in your shell script. In your shell script you need to check whether the file exists or not first or create one.
TRANSLOG=/tmp/translog.txt
if [ -e $TRANSLOG ]; then
echo "File translog already exists!"
else
echo >> $TRANSLOG
fi
echo -e "line1" > $TRANSLOG;
echo -e "line2" > $TRANSLOG;

user3004356
- 870
- 4
- 16
- 49