Renaming Groups of Files From the Command Line
Today’s modular x86 servers are compute-centric, designed as a least common denominator to support a wide range of IT workloads. Those generic, virtualized IT workloads have much different resource optimization requirements than hyperscale and cloud applications. They have resulted in a “one size fits all” enterprise IT architecture that is not optimized for a specific set of IT workloads, and especially not emerging hyperscale workloads, such as web applications, big data, and object storage. In this report, you will learn how shifting the focus from traditional compute-centric IT architectures to an innovative disaggregated fabric-based architecture can optimize and scale your data center.
Sponsored by AMD
Built-in forensics, incident response, and security with Red Hat Enterprise Linux 6
Every security policy provides guidance and requirements for ensuring adequate protection of information and data, as well as high-level technical and administrative security requirements for a system in a given environment. Traditionally, providing security for a system focuses on the confidentiality of the information on it. However, protecting the data integrity and system and data availability is just as important. For example, when processing United States intelligence information, there are three attributes that require protection: confidentiality, integrity, and availability.
Learn more about catching the bad guy in this free white paper.
Sponsored by DLT Solutions
| Making Linux and Android Get Along (It's Not as Hard as It Sounds) | May 16, 2013 |
| Drupal Is a Framework: Why Everyone Needs to Understand This | May 15, 2013 |
| Home, My Backup Data Center | May 13, 2013 |
| Non-Linux FOSS: Seashore | May 10, 2013 |
| Trying to Tame the Tablet | May 08, 2013 |
| Dart: a New Web Programming Experience | May 07, 2013 |
- RSS Feeds
- New Products
- Making Linux and Android Get Along (It's Not as Hard as It Sounds)
- Drupal Is a Framework: Why Everyone Needs to Understand This
- A Topic for Discussion - Open Source Feature-Richness?
- Home, My Backup Data Center
- Developer Poll
- Dart: a New Web Programming Experience
- May 2013 Issue of Linux Journal: Raspberry Pi
- What's the tweeting protocol?
- Reply to comment | Linux Journal
1 hour 5 min ago - Reply to comment | Linux Journal
1 hour 52 min ago - Web Hosting IQ
3 hours 26 min ago - Thanks for taking the time to
5 hours 3 min ago - Linux is good
7 hours 49 sec ago - Reply to comment | Linux Journal
7 hours 18 min ago - Web Hosting IQ
7 hours 48 min ago - Web Hosting IQ
7 hours 48 min ago - Web Hosting IQ
7 hours 49 min ago - Reply to comment | Linux Journal
10 hours 49 min ago
Enter to Win an Adafruit Prototyping Pi Plate Kit for Raspberry Pi

It's Raspberry Pi month at Linux Journal. Each week in May, Adafruit will be giving away a Pi-related prize to a lucky, randomly drawn LJ reader. Winners will be announced weekly.
Fill out the fields below to enter to win this week's prize-- a Prototyping Pi Plate Kit for Raspberry Pi.
Congratulations to our winners so far:
- 5-8-13, Pi Starter Pack: Jack Davis
- 5-15-13, Pi Model B 512MB RAM: Patrick Dunn
- Next winner announced on 5-21-13!
Free Webinar: Linux Backup and Recovery
Most companies incorporate backup procedures for critical data, which can be restored quickly if a loss occurs. However, fewer companies are prepared for catastrophic system failures, in which they lose all data, the entire operating system, applications, settings, patches and more, reducing their system(s) to “bare metal.” After all, before data can be restored to a system, there must be a system to restore it to.
In this one hour webinar, learn how to enhance your existing backup strategies for better disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible bare-metal recovery solution for UNIX and Linux systems.



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!