Hi
I did a script in shell which read a file with some data inside:
for (( read x x Y ))
do
if ["$Y" == "5,"]; then
echo "5"
sed -i '/^[0-9][0-9]*, [0-9][0-9]*, 6,/d' file.txt
else
echo 'fail'
fi
done
when I did it with a while loop it works but too long because the file is very big and do it line by line
so I would like to do it with a loop for and I get this error: syntax error near unexpected token 'done'
Can you help me?
Thanks
EDIT : I would like to know if it's possible to do something like this:
awk 'BEGIN {FS=", "}
{ if ( $3 == "5" )'
echo "5"
sed -i '/^[0-9][0-9]*, [0-9][0-9]*, 6,/d' newfile
'else { print "fail" } }' file
file.txtcorrect?, so the for loop actually is readingfile.txtcorrect? If so, then when "5," is detected, you would have already deleted those lines usingsed. On subsequent detection of "5," , there will be no lines to delete. but you will still be calllingsed. That's your overhead. show a clearer example of your script (don't show it halfway) and show any input files and expected output.[is a command, so it requires a space after it:if [ "$Y" = "5," ]; then ...; fi. Shell syntax is not really C-like.