Skip to content

Instantly share code, notes, and snippets.

@Phrozyn
Created October 8, 2015 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Phrozyn/002f9f121fb982eb1e70 to your computer and use it in GitHub Desktop.
Save Phrozyn/002f9f121fb982eb1e70 to your computer and use it in GitHub Desktop.
Remove enclosing brackets
sed -i 's/\(\[\|\]\)//g' $file
Add a new line after closing brace and comma
sed -i 's/\}\,/}\,\n/g' $file
Add index with type
sed -i 's/{/{"index":{"_index":"<index_name>","_type":"<type>"}}\n{/g' $file
Replace all spaces between two words with underscores
sed -i -e 's/\(\w\)\s\(\w\)/\1_\2/g' $file
Add a new line at the end of the file
sed -i -e '$a\' $file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment