How to find and replace a string in MySQL
UPDATE `table_name` SET `column_name` = REPLACE(`column_name`, 'original_string', 'replace_string')
UPDATE `table_name` SET `column_name` = REPLACE(`column_name`, 'original_string', 'replace_string')
#!/bin/sh # # Script to search recursively for a string in the current directory # if [ "" == $1 ] then echo "Please specify a string to search for." else grep -ril $1 . fi
If you want to look for a string in specific files, you can do the following:
#!/bin/sh # # Script to search recursively for a string in the current directory # find . -type f -name $1 -exec grep -rilo $2 {} \;
grep:
-r = recursive
-i = ignore case distinctions
-l = only print FILE names containing matches
-o = show only the part of a line matching PATTERN
First you want to see which files will be deleted. This examples looks for files older than 7 days.
find /directory/to/search/through/ -type f -mtime +7 -print | xargs echo
If you’re satisfied with the list, you can actually delete them:
find /directory/to/search/through/ -type f -mtime +7 -print | xargs rm -f