Find and replace string in file

find  dir/subdir -type f -exec sed -i 's/foo/bar/g' {} +

Find and replace file owner

find / -user oldname -exec chown newname:newgroup {} \;

Find and remove old dirs (jenkins workspaces)

find /opt/jenkins/workspace -mindepth 1 -maxdepth 1  -type d -mtime +30 -print | xargs /bin/rm -Rf
  • No labels