Renaming Groups of Files From the Command Line
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Sponsored by AMD
If you already use virtualized infrastructure, you are well on your way to leveraging the power of the cloud. Virtualization offers the promise of limitless resources, but how do you manage that scalability when your DevOps team doesn’t scale? In today’s hypercompetitive markets, fast results can make a difference between leading the pack vs. obsolescence. Organizations need more benefits from cloud computing than just raw resources. They need agility, flexibility, convenience, ROI, and control.
Stackato private Platform-as-a-Service technology from ActiveState extends your private cloud infrastructure by creating a private PaaS to provide on-demand availability, flexibility, control, and ultimately, faster time-to-market for your enterprise.
Sponsored by ActiveState
| Non-Linux FOSS: libnotify, OS X Style | Jun 18, 2013 |
| Containers—Not Virtual Machines—Are the Future Cloud | Jun 17, 2013 |
| Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer | Jun 12, 2013 |
| Weechat, Irssi's Little Brother | Jun 11, 2013 |
| One Tail Just Isn't Enough | Jun 07, 2013 |
| Introduction to MapReduce with Hadoop on Linux | Jun 05, 2013 |
- Containers—Not Virtual Machines—Are the Future Cloud
- Non-Linux FOSS: libnotify, OS X Style
- New Products
- Validate an E-Mail Address with PHP, the Right Way
- RSS Feeds
- Introduction to MapReduce with Hadoop on Linux
- Lock-Free Multi-Producer Multi-Consumer Queue on Ring Buffer
- Help with Designing or Debugging CORBA Applications
- Returning Values from Bash Functions
- Linux Systems Administrator
- Welcome to 1998
4 min 21 sec ago - notifier shortcomings
28 min 3 sec ago - heroku?
2 hours 4 min ago - Android User
2 hours 6 min ago - Reply to comment | Linux Journal
3 hours 59 min ago - compiling
6 hours 49 min ago - This is a good post. This
12 hours 2 min ago - Great, This is really amazing
12 hours 4 min ago - These posts are really good
12 hours 5 min ago - It’s a really great site you
12 hours 7 min ago
Featured Jobs
| Linux Systems Administrator | Houston and Austin, Texas | Host Gator |
| Senior Perl Developer | Austin, Texas | Host Gator |
| Technical Support Rep | Houston and Austin, Texas | Host Gator |
| UX Designer | Austin, Texas | Host Gator |
| Web & UI Developer (JavaScript & j Query) | Austin, Texas | Host Gator |
Free Webinar: Hadoop
How to Build an Optimal Hadoop Cluster to Store and Maintain Unlimited Amounts of Data Using Microservers
Realizing the promise of Apache® Hadoop® requires the effective deployment of compute, memory, storage and networking to achieve optimal results. With its flexibility and multitude of options, it is easy to over or under provision the server infrastructure, resulting in poor performance and high TCO. Join us for an in depth, technical discussion with industry experts from leading Hadoop and server companies who will provide insights into the key considerations for designing and deploying an optimal Hadoop cluster.
Some of key questions to be discussed are:
- What is the “typical” Hadoop cluster and what should be installed on the different machine types?
- Why should you consider the typical workload patterns when making your hardware decisions?
- Are all microservers created equal for Hadoop deployments?
- How do I plan for expansion if I require more compute, memory, storage or networking?



Comments
Trying to figure how the command works
Enjoyed the video
Problem:
I can see the removal of the parts, but not the re-arrangement.
Background:
Ok, finally figured out the following:
1) The command uses "substring removal" / "parameter substitution". Took awhile to find this out - my first search term was " ${f# " and got stuff on F# prog language. Live and Learn.
2) The " f# " is for removing the shortest prefix (ie, from the left).
3) The " f$ " is for removing the shortest prefix (ie, from the right).
Problem Restated:
1) Where in the command does it say ----> move the " aa " from the the beginning to the end of the filename?
Correction to the video
1) " f# " is for removing the shortest _not_ the longest prefix
Link that was helpful: Linux Journal Article
I really enjoy learning about the CLI:) and look forward to these videos.
Zeek
Renaming Details
First, if I said "longest" I mis-spoke: "#" and "%" remove the "shortest" match, "##" and "%%" remove the longest match.
The rename command is this:
mv -i $f 2009${f#*-2009}-${%-2009*}There are 4 parts to the final file name:
2009 # Literal ${f#*-2009} # Based on original name - # Literal ${f%-2009*} # Based on original nameGiven the name "aa-2009-01-01". The first substitution removes the shortest prefix that matches "*-2009", in this case that prefix is "aa-2009", leaving "-01-01". The second substitution removes the shortest suffix that matches "-2009*", in this case that suffix is "-2009-01-01", leaving "aa". So the final name is formed from:
2009 ==> 2009 ${f#*-2009} ==> -01-01 - ==> - ${f%-2009*} ==> aaResulting in the file name "2009-01-01-aa", the desired result.
Mitch Frazier is an Associate Editor for Linux Journal.
Thanks
I got it!
Very Clever
That was a surprisingly quick reply - Thanks
Zeek
Cheers
Ways
rename 's/foo/bar/g' *
rename .oldextension .newextension *.oldextension
mmv 'banana_*_*.asc' 'banana_#2_#1.asc'
Bulk renaming : http://is.gd/50bGB
You can also use "rename" command
The "rename" command offers as way to directly do essentially the same thing. It does a find/replace of the groups of files you specify.
Only in a few cases
Rename will work for you in some cases but not all, specifically it wouldn't work for the example in the video, unless I'm missing something...
Mitch Frazier is an Associate Editor for Linux Journal.
rename will work with
rename will work with regex...
rename s/\(..\)-\(.*\)/\$2-\$1/ *2009*... but I never considered this usage of parameter substitution. Thanks!