My Favorite New Bash Command Line

A while ago I found an article entitled Top Ten One-Liners from CommandLineFu Explained, and I liked the example to quickly create backup files. Well, today I had some kind of Perforce problem after I renamed a couple of files, and I couldn’t submit the changelist, but I also wasn’t allowed to resolve anything.

So I decided to use my new CommandLineFu to make a backup, revert, checkout and copy the backup back over. It was amazingly simple:

cp FindReachableMethods.java{,.save}
p4 revert FindReachableMethods.java
p4 edit FindReachableMethods.java
mv FindReachableMethods.java{.save,}

Line 1 copies FindReachableMethods.java to FindReachableMethods.java.save. The {,.save} part expands to two arguments, the first one being just the preceding file name, the second the preceding file name with .save attached. In line 4, I move the files, but in the opposite direction.

Share

About Mathias

Software development engineer. Principal developer of DrJava. Recent Ph.D. graduate from the Department of Computer Science at Rice University.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply