I am trying to add license declaration to all files inside a folder. Is there any shortcuts / linux commands to do that? If this can be done to files of a specific extension that will be even better.
Edit: This was my final command based on @vimsha's answer: find . -type f -name "*.js" -exec sh -c 'echo "/* @flow */\\n$(cat $0)" > $0' {} \\;
find . -type f -name "*.js" -exec sh -c 'echo "/* @flow */\\n$(cat $0)" > $0' {} \\;
cd into the folder and execute the following command
find *.txt -exec sh -c 'echo "license " >> $0' {} \;
Above command finds all files with 'txt' extension and appends the string "license" to them. You can change it to the extension you want and the text you want to append
To add to the beginning of the file:
find *.txt -exec sh -c 'echo -e "license\n$(cat $0)" > $0' {} \;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.