On Tue, 16 Jan 2001, Austad, Jay wrote: > Ok, I have this shell script that pipes some stuff to xargs. Some of the > stuff has lone single quotes in it and breaks the pipe to xargs because of > an unmatched quote error. So to fix this, I do something like: > > cat filname.txt | perl -pi -e "s/\'/\\\'/g" | xargs .... perl -pi -e "s/(\W)/\\$1/g" should do the trick - \W looks for all non alphanumeric characters - putting it in parenthesis turns it into a segment for backreferencing, $1 is the backreference variable > > How can I modify that perl statement so it will take single quotes, double > quotes, greater/less than signs, question marks, and asterisks, and replace > them with a backslash and then themselves? > > * would be \* > ? would be \? > " would be \" > and so on. > > I don't want to have a bunch of -e statements in my little perl command. > > Jay > _______________________________________________ > tclug-list mailing list > tclug-list at mn-linux.org > https://mailman.mn-linux.org/mailman/listinfo/tclug-list > -- Imagination is intelligence having fun... e-mail: kethry at winternet.com URL: http://WWW.winternet.com/~kethry/index.html