Minor correction and explanation: to follow
LAMMPS data files are simple text files. You an use a text editor to
extract the Angles section. (Or use "extract_lammps_data.py").
Then throw away lines if the angle-type (2nd column) is not the type
you want. (You can do that in many ways, for example using awk or a
spreadsheet program, or your own script. The example below uses awk.)
Finally update the number of angles in the header at the top of the data file.
############# EXAMPLE #############
# You can cut and paste this text into a (bash) terminal.
# Suppose your old data file is named "old_file.data".
# I assume you want to delete angles of type 1.
# (If not change "1" to "2" in the awk command below.)
extract_lammps_data.py Angles < old_file.data > old_angles.txt
awk '{if ($2!=1) print $0}' < old_angles.txt > new_angles.txt
extract_lammps_data.py -n Angles < old_file.data > temp_file.data
The lines above, extracted the "Angles" section of the data file, and
saved it as a seperate file ("new_angles.txt"). The remaining text is
saved in a temporary file ("temp_file.data").
We need to put the "Angles" section back in the "temp_file.data". It
does not matter where we put it as long as we preceed it with 3 lines:
(blank line)
Angles
(blank line)
echo "" >> temp_file.data
echo "Angles" >> temp_file.data
echo "" >> new_file.data (oops WRONG)
sorry, that should have been
echo "" >> temp_file.data
Then we append new list of angles to the end of "temp_file.data":
cat new_angles.txt >> temp_file.data
# Almost done...
# Count the number of remaining angles. (One way is using
# "wc" to count the number of lines in the "new_angles.txt" file):
NUM_ANGLES=`wc -l new_angles.txt`
# ...and replace the line at the beginning with the correct angle count:
awk -v num_angles=$NUM_ANGLES \
'{if ((NF==2) && ($2=="angles"))
print num_angles" angles";
else
print $0;}' < temp_file.data > new_file.data
##########################
I did not test all of this, but I think it works.
Hopefully, you get the idea.
Awk, grep, sed, cut, paste, wc...
...all useful things to know
Cheers
Andrew