Skip to content

Instantly share code, notes, and snippets.

@rfinz
Last active October 8, 2019 16:47
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 rfinz/37380cbef6c81244793e to your computer and use it in GitHub Desktop.
Save rfinz/37380cbef6c81244793e to your computer and use it in GitHub Desktop.
find /path/to/files* -mtime +5 -exec rm {} \; # delete files older than 5 days
find /path/to/files* -type d -mtime +5 -mindepth 1 -exec rm -r {} \; # delete folders older than 5 days
find ~salsa-server/.salsa.d/latest -regextype posix-egrep -regex '^TPMRO1Agile-cpdec[0-9]{3}-[0-9]{1}-[0-9]{10}-PictureDescription\.[0-9a-zA-Z]+-[0-9a-zA-Z_-]+(Response|\.txt)$' -exec cp {} /home/data/tpmdata/PD \; #find files matching regex and copy them to new folder
tar cf - /folder-with-big-files -P | pv -s $(du -sb /folder-with-big-files | awk '{print $1}') | gzip > big-files.tar.gz # see progress when compressing large data
pdftotext my.pdf - | grep 'pattern' # grep in pdf
find /path -iname '*.pdf' -exec pdfgrep pattern {} + # another grep in pdf solution using pdfgrep
for i in *.txt; do content=$(<$i); echo "{\"text\": \"${content}\"}" >> texts.jsonl; done # echo all txt files into a jsonl file
for i in *.xml; do mv $i "${i%.xml}.txt"; done # change the extension of a bunch of files (in this case xml to txt)
for i in *.txt; do n1=$(<$i); n2=$(< ~/Downloads/txt/$i); [[ ${#n1} == ${#n2} ]] && echo -n "" || echo "$i"; done # echo file names if different number of bytes
for pod in $(kubectl get pods | grep mm-sa | awk '{print $1}'); do echo $pod; kubectl logs $pod | grep -C 10 'Exception'; done # get 'Exception' instances from pods named with 'mm-sa'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment