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_//'`
? end
# ls
filename_etc1 filename_etc2 filename_etc3 filename_etc4
# zsh
# ls
prependPID_filename_etc1 prependPID_filename_etc2 prependPID_filename_etc3 prependPID_filename_etc4
# for i in prependPID*
for> mv $i `echo $i | sed 's/prependPID_//'`
# ls
filename_etc1 filename_etc2 filename_etc3 filename_etc4
This blog covers Unix system administration HOWTO tips for using inline for loops, find command, Unix scripting, configuration, SQL, various Unix-based tools, and command line interface syntax. The Unix OS supports tasks such as running hardware, device drivers, peripherals and third party applications. Share tips/comments. Read the comments. But most importantly: Read Disclaimer - Read Disclaimer.
Friday, October 03, 2008
Subscribe to:
Posts (Atom)