From: hadi motamedi <motamedi24@xxxxxxxxx> > On 11/29/10, John Doe <jdmls@xxxxxxxxx> wrote: > > cat edit.txt | while read LINE; do > > echo "$LINE" | grep -q '>\.\.' > > if [ $? -eq 0 ]; then > > LOGFILE=`echo $LINE | cut -d' ' -f1`.log > > else > > echo "$LINE" >> $LOGFILE > > fi > > done > Thank you very much for your help. I tried for your code but I am > receiving the following error: > -bash:[1:command not found > -bash:$LOGFILE:ambiguous redirect > Can you please correct me? The trick is that your original file has '\r' chars lurking around... Forgot I did removed them manualy when I saw them... cat Edit3 | tr -d "\r" | while read LINE; do Instead of just copy/pasting, try to understand what it does. Here is how it works: - Read each line in the LINE variable. - If the line contains the string '>..', it is a "section" line. Set the log filename to the section title. - If not, just write the line to the current log filename. JD _______________________________________________ CentOS mailing list CentOS@xxxxxxxxxx http://lists.centos.org/mailman/listinfo/centos