Skip to content

Instantly share code, notes, and snippets.

@LukeSmithxyz
Created April 10, 2019 13:29
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save LukeSmithxyz/ffd3f2ca1deac65423c2f32930294b65 to your computer and use it in GitHub Desktop.
#!/bin/sh
sed "
s/title\s*=\s*{\(.*\)},*/%T \1/I
s/author\s*=\s*{\(.*\)},*/%A \1/I
s/publisher\s*=\s*{\(.*\)},*/%I \1/I
s/doi\s*=\s*{\(.*\)},*/%K \1/I
s/journal\s*=\s*{\(.*\)},*/%J \1/I
s/volume\s*=\s*{\(.*\)},*/%V \1/I
s/number\s*=\s*{\(.*\)},*/%N \1/I
s/pages\s*=\s*{\(.*\)},*/%P \1/I
s/year\s*=\s*\([0-9]*\),*/%D \1/I
s/^\s*//g
/^[^%]/d
s/\({\|}\)//g
" "$@"
@3ed
Copy link

3ed commented Apr 10, 2019

Interesting thing with hashbangs is that almost everything can be interpreter. Not very big optimization but... :) (v=bkgeFi4PwOg)

#!/bin/sed -f

s/title\s*=\s*{\(.*\)},*/%T \1/I
s/author\s*=\s*{\(.*\)},*/%A \1/I
s/publisher\s*=\s*{\(.*\)},*/%I \1/I
s/doi\s*=\s*{\(.*\)},*/%K \1/I
s/journal\s*=\s*{\(.*\)},*/%J \1/I
s/volume\s*=\s*{\(.*\)},*/%V \1/I
s/number\s*=\s*{\(.*\)},*/%N \1/I
s/pages\s*=\s*{\(.*\)},*/%P \1/I
s/year\s*=\s*\([0-9]*\),*/%D \1/I
s/^\s*//g
/^[^%]/d
s/\({\|}\)//g

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