find old domain names... and fixing them

time find . -type f -name "*.html" | xargs grep -i wagoneers.com | wc -l this ran into some issues while looking for wagoneers.com... --> time find . -type f -name "*.html" | xargs grep wagoneers.com | wc -l xargs: unmatched single quote; by default quotes are special to xargs unless you use the -0 option Before I had time to chase it down, one of the guys from the lunch session suggested this command: find . -name '*.html' | grep "'" And that pointed to a file buried way deep in some old pages... and turns out some info someone had sent to me in a zip file, I unzipped it and parked it... and it had single quotes in it! Ok, so once that was found I ran my "fix-filenames" script #!/bin/bash ############################################################################################### # 2014_05May_09 - john meister copyright 2014 http://LinuxMeister.net # script to remove spaces in file names and replace with underscore # cleans up web pages by eliminating special characters and allows sorts to work properly # to use place this script in your path and make it executable, then cd to the directory # and execute by the saved name (fix-filename) - works on Linux and MacOS ############################################################################################### # removes spaces, special characters, slashes, and _-_ but NOT caps ############################################################################################### for f in * do mv -v "$f" `echo $f | tr ' ' '_' | tr -d '[{}(),\!]' | tr -d "\'" | sed 's/&/-n-/g' | sed 's/_-_/_/g'` done -------- then I proceeded to find the files with wagoneers.com and gathered them up, sorted through them and then created the perl/find commands below. Ran a few manually, and then let the script run the rest. # #!/bin/bash # # -------------------------------------- fixing wagoneers.com 9/12/2018 john # # find . -name '*.html' | grep "'" # # cd fotos/2003/10-Oct-2003/ # # fix-filenames # # time find . -type f -name "*.html" | xargs grep -i wagoneers.com | wc -l # # ll jeep/HOLD-JEEPS/XJ/tech/MISC/MANUALS/00xj/ # # cd jeep/HOLD-JEEPS/XJ/tech/MISC/MANUALS/00xj/ # # fix-filenames # # time find . -type f -name "*.html" | xargs grep -i wagoneers.com | tee -a files-with-wagoneers.com.txt # # vi files-with-wagoneers.com.txt # # cat wagoneers.com-files-to-fix.txt | uniq | wc -l # # cat wagoneers.com-files-to-fix.txt | uniq -d | wc -l # # cat wagoneers.com-files-to-fix.txt | uniq -d > wagoneers.com-files-to-fix-short-uniq-d.txt # # vi wagoneers.com-files-to-fix-short-uniq-d.txt # # ----------- # # find . -type f -name '*.html' | xargs perl -pi -e 's$//ws.##FIX##$//ws-na.amazon-adsystem.com$g' # # find . -type f -name '*.html' | xargs grep rcm.##FIX## # # ----------- # # ----------------------------------------------------- # # find . -type f -name '*.html' | xargs grep " # # # # " # # find . -type f -name '*.html' | xargs perl -pi -e 's # # $ # # $ # # $g' # # ----------------------------------------------------- # # find . -type f -name '*.html' | xargs grep "Shop - Amazon.com" | wc -l # # find . -type f -name '*.html' | xargs perl -pi -e 's$<A HREF="http://wagoneers.com/amazon" target="_blank"> Shop - Amazon.com</a>$$g' # # find . -type f -name '*.html' | xargs grep "Shop - Amazon.com" # #----------------------------------------------------- # # find . -type f -name '*.html' | xargs grep "<a href=\"http://wagoneers.com/amazon/recommended.html\">(click for recommendations)</a>" # # find . -type f -name '*.html' | xargs perl -pi -e 's$<a href="http://wagoneers.com/amazon/recommended.html">(click for recommendations)</a>"$$g' # # find . -type f -name '*.html' -exec perl -pi -e 's$<a href="http://wagoneers.com/amazon/recommended.html">(click for recommendations)</a>"$$g' {} \; # # find . -type f -name '*.html' -exec perl -pi -e 's$wagoneers.com/amazon/recommended.html$$g' {} \; # # ----------------------------------------------------- # # ----------------------------------------------------- # # find . -type f -name '*.html' | xargs perl -pi -e 's$www.wagoneers.com/.images/$http://johnmeister.com/.pix/$g' # #----------------------------------------------------- # #----------------------------------------------------- # find . -type f -name '*.html' | xargs perl -pi -e 's$wagoneers.com/john/GIF/$johnmeister.com/.pix/$g' # #----------------------------------------------------- # #----------------------------------------------------- # find . -type f -name '*.html' | xargs perl -pi -e 's$wagoneers.com/FSJ$johnmeister.com/jeep/sj$g' # #----------------------------------------------------- # #----------------------------------------------------- # find . -type f -name '*.html' | xargs perl -pi -e 's$wagoneers.com/XJ$johnmeister.com/jeep/XJ$g' # #----------------------------------------------------- # find . -type f -name '*.html' | xargs perl -pi -e 's$<A HREF=\"http://wagoneers.com/amazon\" target=\"_blank\"> Shop - Amazon.com</a>$$g' # #----------------------------------------------------- # find . -type f -name '*.html' | xargs perl -pi -e 's$wagoneers.com/WJ$johnmeister.com/jeep/WJ$g' # #----------------------------------------------------- # #----------------------------------------------------- # find . -type f -name '*.html' | xargs perl -pi -e 's$wagoneers.com/Willys$johnmeister.com/jeep/Willys$g' # #----------------------------------------------------- # #----------------------------------------------------- # find . -type f -name '*.html' | xargs perl -pi -e 's$wagoneers.com/JEEPS$johnmeister.com/jeep$g' # #----------------------------------------------------- # #----------------------------------------------------- # find . -type f -name '*.html' | xargs perl -pi -e 's$wagoneers.com/DieselBenz$johnmeister.com/tech/Mercedes$g' # #----------------------------------------------------- # #----------------------------------------------------- # find . -type f -name '*.html' | xargs perl -pi -e 's$wagoneers.com/CS/LINUX$johnmeister.com/linux$g' # #----------------------------------------------------- # #----------------------------------------------------- # find . -type f -name '*.html' | xargs perl -pi -e 's$wagoneers.com/UNIX$johnmeister.com/linux$g' # #----------------------------------------------------- # #----------------------------------------------------- # find . -type f -name '*.html' | xargs perl -pi -e 's$wagoneers.com/DIESELS$johnmeister.com/tech/Diesel$g' # #----------------------------------------------------- # #----------------------------------------------------- # find . -type f -name '*.html' | xargs perl -pi -e 's$fotomeister.us$johnmeister.com$g' # #----------------------------------------------------- # #----------------------------------------------------- # find . -type f -name '*.html' | xargs perl -pi -e 's$wagoneers.com$johnmeister.com$g' # #----------------------------------------------------- # #----------------------------------------------------- # ------------------------------------------------ # --> sh ./fix-wagoneers.com.sh.txt # Can't open ./HD-DECK/STILLS_HD/2017/20170504/HEADER.html: No such file or directory, <> line 2200904. # Can't open ./2015/01-Jan-26-Mtns-n-Mac-sunny-Monday/HEADER.html: No such file or directory, <> line 648656 (NOT SURE WHAT THAT ERROR IS ABOUT... yet) --> time find . -type f -name "*.html" | xargs grep -i wagoneers.com | wc -l 376 real 4m31.228s user 2m8.418s sys 0m3.630s THIS MAKES SENSE as I have Wagoneers.com on pages... so I reran the command with out the -i and... ------------------------------------------------ --> time find . -type f -name "*.html" | xargs grep wagoneers.com | wc -l 27 real 1m4.123s user 0m4.456s sys 0m2.951s ------------------------------------------------ --> time find . -type f -name "*.html" | xargs grep wagoneers.com ./linux/Scripts/Using-find-perl-to-fix-wagoneers.com.html:# ... ...NOW THAT'S FUNNY... the 27 occurrences were in THIS file... the script used to change the names! web site updated... ready for the linux at lunch session...

JohnMeister.com Today's Date:

Simply Linux: Basics  Full Size Jeep Buyer's Guide Using BASH on Windows 10
Practical Suggestions for Microsoft Windows
Linux Tackles Microsoft
Video Course:
The Art of Linux System Administration, and a
Study Guide for the LPIC-2 Certification Exams.

-- O'Reilly Media author info
FULL SIZE JEEP

Buyer's Guide

SJ model Jeeps
"Jeep is America's
only real sports car."
-Enzo Ferrari


Mercedes, VW, and other Diesels
Nikon cameras
general tech info
AMSOIL product guide,
or, AMSOIL web, or 1-800-956-5695,
use customer #283461

Amsoil dealer since 1983

purchase AMSOIL and have it
installed locally in WA at:

- Fleet Services 425.355.4440 - Everett
- Midway Auto 360.668.7111 - Clearview/Snohomish
- Northland Diesel 360.676.1970 - Bellingham