![]() This invoked file on one file at a time, so it's slightly slower. If you don't have zsh, you can use ls and cope with file names that contain spaces but not newlines or trailing spaces by passing the -L1 option to file. nfo -type f -print0 xargs -0 sed -i s/pattern/replacement/. Recent versions of GNU sed can use null bytes as the record delimiter instead of newlines. This tells find and xargs to use null characters (which cannot appear in file names) as a separator between file names, and xargs not to do any other parsing which would mangle file names containing spaces. Beware that in this case the path itself shouldnt contain a string test. 2 days ago &0183 &32 How to Find Most Used Disk Space Directories, Files in Linux. In general, though, the -print0 GNU find extension works fine for many other scenarios (too), and you should learn to use it in any event. It finds the files in the current working directory recursively, echoes the original file name ( p) and then a modified name ( s/test/spec/) and feeds it all to mv in pairs ( xargs -n2 ). Most utilities which can read a bunch of file names would choke on a shell-escaped name, but it would in fact make sense for (say) find to offer an option to output file names in a format suitable for the shell. If you need to cope with absolutely all file names, including those with a newline in their name, use the -0 option for null-delimited output. name 'test.rb' sed -e 'p s/test/spec/' xargs -n2 mv. file -mime-type *(om) | sed -n 's~: *image/*$~~p' 4 Answers Sorted by: 3 printf
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |