- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Script to rename core files and put them in an arc...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2002 02:33 AM
09-18-2002 02:33 AM
I put a simple script together that should collect the the core files on my system, rename them by putting an '_' instead of a '/', so that the files could be individually placed in an archive directory. It dosen't work. Can someone tell me why?:
ARCHIVE_DIR="/archive/core_files"
for file in 'find / -name core'
do
target_name='echo $file ?? awk '{print sub(".", "/")}
mv $file $ARCHIVE_DIR/$target_name
done
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2002 02:41 AM
09-18-2002 02:41 AM
Re: Script to rename core files and put them in an archive
target_name='echo $file ?? awk '{print sub(".", "/")}
is missing a '
Instead of using 's use $() to enclose command substitutions.
ie:
target_name=$(echo $file ?? awk '{print sub(".", "/")})
I'd recommend changing the find too.. -local at least.
watch out for files really called core - to the best of my knowledge there's one in /opt/netscape that should be called core.
You also don't want to move dirs and possibly want to redirect stderr to /dev/null
Later,
Bill
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2002 02:44 AM
09-18-2002 02:44 AM
Re: Script to rename core files and put them in an archive
ARCHIVE_DIR="/archive/core_files"
for file in $(find / -name core)
do
target_name=$(echo $file | sed 's%/%_%g')
mv $file $ARCHIVE_DIR/$target_name
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2002 03:19 AM
09-18-2002 03:19 AM
Re: Script to rename core files and put them in an archive
ARCHIVE_DIR="/archive/core_files/"
for file in `find . -name core`
do
mv $file ${ARCHIVE_DIR}`echo $file |tr "/" "_"`
done
The filenames can be rather long.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2002 04:16 AM
09-18-2002 04:16 AM
Re: Script to rename core files and put them in an archive
find / -file core -exec mv /archive/core_files {} \;
Just a thought,
Rita
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2002 07:42 AM
09-18-2002 07:42 AM
Re: Script to rename core files and put them in an archive
Rita, that was the first thing that came to my mind. But, if you try it out and think about it carefully you'll also see why it won't work.
Leif, I tried it but got an error message. I'll have to look into it. The idea is great . I hadn't thought about piping it using 'tr'.
Dieter, it looks like it will work. Il'll try it out tomorrow.
Bill, you noticed my typing errors. Thanks for your good suggestions.
This is what it looks like now and it works:
DATETIME=`date +%y%m%d%H%M`
ARCHIVE_DIR="/archive/core_files/"
for file in `find / -name core`
do
name=`echo $file | awk '{print substr( $0,length-3 )}'`
target_path=`echo $file | awk '{print substr( $0,1,length-5 )}'`
target_name_path=`echo $target_path | awk 'gsub ( "/","_") { print $0} '`
target_own_grp=`ls -al $file | awk '{ print $3"_"$4 }'`
mv $file $ARCHIVE_DIR$name$target_name_path"_"$target_own_grp"_"$DATETIME
done
Ron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2002 08:00 AM
09-18-2002 08:00 AM
Solutionname=`basename $FOUND_CORE_FILE`
dir=`dirname $FOUND_CORE_FILE`
Seems a bit easier than stripping with awk anyway.
Regards,
Shannon
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2002 09:14 AM
09-18-2002 09:14 AM
Re: Script to rename core files and put them in an archive
Will this work?
find / -type f -name core | while read core; do mv $core /archive/core_files/$(echo $core | sed -e 's%/%_%g'); done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2002 09:39 AM
09-18-2002 09:39 AM
Re: Script to rename core files and put them in an archive
find / -name core -type f
Just in case some user or application has a directory called "core".
And yes, we have one - on our oracle/sap servers there is a core dir that contains what they refer to as "core" components.
After all, you wouldn't want to move a directory to your archive...
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-18-2002 11:09 AM
09-18-2002 11:09 AM
Re: Script to rename core files and put them in an archive
A small modification (delete the "." in the beginning of the filenames).
ARCHIVE_DIR="/tmp/core_files/"
for file in `find . -name core`
do
mv $file ${ARCHIVE_DIR}`echo $file |tr "/" "_" | tr -d "."`
done
I created a small directory tree with a "core" file in each directory and run the script. In the "ARCHIVE_DIR" I got:
core_files:
_aax_bbx_core _aax_core _core
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2002 03:43 AM
09-19-2002 03:43 AM
Re: Script to rename core files and put them in an archive
To turn it on:
echo "core_addpid /w 1" | adb -w /stand/vmunix /dev/kmem