Using Sed.

I had the need to change a directory listing of all files on a server from a name such as f:\directory\fred.doc to DIRECTORY/FRED.DOC ie to remove the f:, swap \ to / and uppercase all the files. Using SED I was able to do all of those using repeated substitutions like the following, sed “s/f:\\i/i/;s/\\/\//g;s/a/A/g;s/b/B/g;s/c/C/g;s/d/D/g;s/e/E/g;…s/y/Y/g;s/z/Z/g” . Thats a really powerful utility and very complicated. I’m sure there is an easier way to UPCASE the characters but I didn’t have the time to discover it. For those of you curious as to why I need to do this, its because I’m creating a cpio of some data on nt, and copying it to unix. If I uncpio’d the data on a unixbox, the backslashes acting as directorys would just be treated as a normal file character.


Comments are closed.