Most Popular in Unix
-
Random Hacking: Network Unlocking a Sony Ericsson w300i mobile phone
-
Most Highly Recommended Solaris Security Tools
-
Strip a Prepended String From a Filename - Unix
-
IrfanView - Comprehensive Graphic Viewer for Windows
-
How can i use fork,sleep,wait and write in a process with father and son..??
-
Forays into C++
-
The Admin Zen: Keep it up and running.
-
VBoxHeadless - Running Virtual Machines With VirtualBox 2.0 On A Headless Ubuntu 8.04 Server
-
How to detect browser and re-direct
-
Manage Widget Geometry in PyGTK (28 May 2008)
Strip a Prepended String From a Filename - Unix
Article posted from
My SysAd Blog (http://www.mysysad.com/2008/10/strip-prepended-string-from-filename.html)
I had a process that was pre-pending by design its PID to a file name string. But unfortunately, it caused a few unexpected problems when this handling process inadvertently terminated. I had to rename the files without the defunct pre-pended PID string and then reprocess them (several thousand).
Here is what I used as a quick and dirty procedure.
# csh
# ls
prependPID_filename_etc1 prependPID_filename_etc2 prependPID_filename_etc3 prependPID_filename_etc4
# foreach filename (prependPID*)
? mv $filename `echo $filename | sed 's/prependPID_//g'`
? end
# ls
filename_etc1 filename_etc2 filename_etc3 filename_etc4
Here is what I used as a quick and dirty procedure.
# csh
# ls
prependPID_filename_etc1 prependPID_filename_etc2 prependPID_filename_etc3 prependPID_filename_etc4
# foreach filename (prependPID*)
? mv $filename `echo $filename | sed 's/prependPID_//g'`
? end
# ls
filename_etc1 filename_etc2 filename_etc3 filename_etc4
More Stories in My SysAd Blog
- Strip a Prepended String From a Filename - Unix
- IrfanView - Comprehensive Graphic Viewer for Windows
- Mounting ISO and DD Image Files
- Hardware Mismatch for Fibre Channel Hard Drive
- Unable to Switch User Error - su: no shell
- iPod Disconnected During Recharge
- Citrix Users Report Login Issue on Unix Workstation
- System Administrator Appreciation Day
- Inadvertent Use of Duplicate Group ID
- UNIX Admin Corner and the IT Island
Most Popular Stories
New Lawsuit Adds Hairline Cracks to List of iPhone Problems
Another variant of RSPlug trojan for Mac pops up
Darik's Boot and Nuke is the Nuclear Option of Secure Data Shredding
Apple flirting with another record quarter for Mac sales
The G1's Deepest, Darkest Secret: Hidden Multitouch
Why now, Omnioutliner?
Apple waiting on quad-core desktop chips from Intel
Husband Blames iPhone For Smutty Pic Debacle, Fate of Marriage Hangs on Apple Support Discussion
Ask TUAW: Apple TV, Blu-ray on the Mac, solving SIMBL problems, and more