Skip to content

Instantly share code, notes, and snippets.

@pcsanwald
Created July 8, 2012 14:37
Show Gist options
  • Save pcsanwald/3071225 to your computer and use it in GitHub Desktop.
Save pcsanwald/3071225 to your computer and use it in GitHub Desktop.
name java files according to their public class declaration
# The regular expression checks for a public class declared in the file.
# The match, captured using the $1 variable, then is used to rename the file according
# to java conventions, i.e. ClassName.java
perl -ne '/public class ([a-zA-Z0-9]+) / && rename($ARGV,$1.".".java)' *
# I created this gist because manning ships the source code for "Hadoop in Action" in files called
# "listing-2-2", with no indication what kind of file it is.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment