Skip to content

Instantly share code, notes, and snippets.

@huozhi
Last active September 19, 2022 20:58
Show Gist options
  • Save huozhi/4f4db2c892a092db0ebc66ca8865868c to your computer and use it in GitHub Desktop.
Save huozhi/4f4db2c892a092db0ebc66ca8865868c to your computer and use it in GitHub Desktop.
inesert text to files
# https://stackoverflow.com/questions/61546603/bash-find-file-and-insert-text-in-beginning-of-empty-and-non-empty-files
# insert `'client'\n` to all .client.tsx files
find . -type f -name '*.client.tsx' -print0 | while IFS= read -rd '' file; do ed -s "$file" <<< $'0a\n\'client\'\n\n.\nw\nq'; done
# rename files
ls | grep \.png$ | sed 'p;s/\.png/\.jpg/' | xargs -n2 mv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment