Skip to content

Instantly share code, notes, and snippets.

@awesomebytes
Created January 25, 2016 15:20
Show Gist options
  • Select an option

  • Save awesomebytes/3c09fbc2c870beecb06f to your computer and use it in GitHub Desktop.

Select an option

Save awesomebytes/3c09fbc2c870beecb06f to your computer and use it in GitHub Desktop.
One line (kinda long) regular expression substitution in python (for when sed refuses to obey)

One liner python regexp substitution (aka sed-you-should-be-doing-this-properly)

cat only_arm.urdf | python -c "import sys,re;sys.stdout.write(re.sub('<gazebo(.|\n)*?<\/gazebo>*', '', sys.stdin.read()))" > only_arm.urdf.nogazebo 

This was to delete gazebo tags in an URDF file in a single commandline with things that (usually) come with the base system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment