How do the UNIX commands mv and rm work with open files?

Unix filesystems use reference counting and a two-layer architecture for finding files. The filename refers to something called an inode, for information node or index node. The inode stores (a pointer to) the file contents as well as some metadata, such as the file’s type (ordinary, directory, device, etc.) and who owns it. Multiple filenames … Read more

How to rename with prefix/suffix?

You could use the rename(1) command: rename ‘s/(.*)$/new.$1/’ original.filename Edit: If rename isn’t available and you have to rename more than one file, shell scripting can really be short and simple for this. For example, to rename all *.jpg to prefix_*.jpg in the current directory: for filename in *.jpg; do mv “$filename” “prefix_${filename}”; done; or … Read more

Is it possible to move/rename files in Git and maintain their history?

Git detects renames rather than persisting the operation with the commit, so whether you use git mv or mv doesn’t matter. The log command takes a –follow argument that continues history before a rename operation, i.e., it searches for similar content using heuristics. To lookup the full history, use the following command: git log –follow … Read more

tech