Skip to content

Instantly share code, notes, and snippets.

@grhawk
Last active May 10, 2016 10:55
Show Gist options
  • Save grhawk/b3cd79e8c1ca64d54b6af224fa3cc82f to your computer and use it in GitHub Desktop.
Save grhawk/b3cd79e8c1ca64d54b6af224fa3cc82f to your computer and use it in GitHub Desktop.
i-Pi input editing
#!/bin/bash
# To edit file in place use the '-L' option wih the ed command
# Name of the file to edit
namefile='input_hexamer_book.xml'
# Assign the name of the ffsocket to a variable
ffname=`xmlstarlet sel -t -v "/simulation/ffsocket/@name" $namefile`
# Add the forcefield attribute to the force tag and put $ffname as the value of the just added attribute.
#+Moreover remove all values from the force tag.
xmlstarlet ed -i "/simulation/system/forces/force" --type attr -n 'forcefield' -v $ffname -u "/simulation/system/forces/force" -v '' $namefile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment