Skip to content

Instantly share code, notes, and snippets.

@stefanofiorentino
Last active April 20, 2020 16:17
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 stefanofiorentino/7c88276a7b59c49599d3ef84b5d90efc to your computer and use it in GitHub Desktop.
Save stefanofiorentino/7c88276a7b59c49599d3ef84b5d90efc to your computer and use it in GitHub Desktop.
remove pragma onces at once
#!/bin/bash
# grep -rn "#pragma once" src/* | sed 's/:1:#pragma once//g' > file_list
for name in $(cat file_list);
do
echo $name;
cleaned=$(echo $name | sed 's/src\/uvw\///g' | sed 's/\.hpp//g' | sed 's/\.h//g')
echo $cleaned
upper=$(echo $cleaned | tr '[a-z]' '[A-Z]' | xargs -r -n1 -I {} echo UVW_{}_INCLUDE_H)
echo $upper
guards=$(echo $upper | xargs -r -n1 -I {} echo "#ifndef {}\\n#define {}")
echo $guards
sed -i "s/#pragma once/${guards}/g" "$name"
echo >> $name
echo "#endif // ${upper}" >> $name
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment