Last active
September 13, 2024 19:43
-
-
Save hanminghui/965475d3034cb858ad5eca80d28c8393 to your computer and use it in GitHub Desktop.
[Shell Scripts] some shell scripts #shellscripts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # there are many subdirectories, and each file has a .tgz file in it. | |
| # run this to check path, test first | |
| for d in ./*/ | |
| do (cd $d && echo $PWD) | |
| done | |
| # run this to extrat files to its directory. | |
| for d in ./*/ | |
| do (cd $d && find . -name '*.tgz' -not -name '.*' -exec tar xvzf {} -C $PWD \;) | |
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # there are many [name].py and ._[name].py files in a directory | |
| # first use find to find only the [name].py files | |
| # then use sed to change the first line, and also make a backup | |
| find -name "*.py" -not -name ".*" -exec sed -i.bak "1 s/^.*$/#! \/usr\/bin\/python2/" {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment