To avoid having to remember this, I use an interactive bash script, as follows: #!/bin/bashĮcho "Find and replace in current directory!"Įcho "File pattern to look for? (eg '*.txt')"Įcho "Replacing all occurences of $existing with $replacement in files matching $filepattern"įind. regex './foo//.doc' -printf 'i ' wc -l (The i format code causes find to print the inode number instead of the filename unlike the filename, the inode number is guaranteed to not. regex './foo//.doc' To just count the number of files: find. Note that the 'without a backup' part in line 4 is OK for me, because the files I'm changing are under version control anyway, so I can easily undo if there was a mistake. With gnu find you can use regex, which (unlike -name) match the entire path: find. In other words, it will look into sub-directories too. The -r option read/sarch all files under each directory, recursively, following symbolic links only if they are on the command line.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |