- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Script help, just to make a change :)
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
10-01-2003 02:47 AM
10-01-2003 02:47 AM
2003_08_27_NE:31.all.cdl
The datestamp varies as do the two digits after NE:
Cheers
George
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2003 02:57 AM
10-01-2003 02:57 AM
Re: Script help, just to make a change :)
cd /the/folder
ls | perl -ne 'chomp;$orig=$_;s/://;system("mv $orig $_")'
This assumes that their will be no conflict in names (ie duplicate names).
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2003 03:03 AM
10-01-2003 03:03 AM
Re: Script help, just to make a change :)
Here is one way to do it:
for oldfile in *:*
do
newfile=$(echo $oldfile | sed s/\://)
echo "Renaming $oldfile to $newfile"
mv $oldfile $newfile
done
JP
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2003 03:04 AM
10-01-2003 03:04 AM
Re: Script help, just to make a change :)
#!/usr/bin/sh
ls [0-9][0-9][0-9][0-9]_[0-9][0-9]_[0-9][0-9]_NE:[0-9][0-9].all.cdl | while read X
do
NEWNAME=$(echo ${X} | tr -d ":")
mv ${X} ${NEWNAME}
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2003 03:04 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2003 03:11 AM
10-01-2003 03:11 AM
Re: Script help, just to make a change :)
Ta
George
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2003 04:28 AM
10-01-2003 04:28 AM
Re: Script help, just to make a change :)
#!/bin/sh
for name in `ls *:*`
do
ch_name=`echo $name|awk -F':' '{print $1$2;}'`
mv $name $ch_name
done
Could i use sed to replace the .all.cdl ending with .txt ?
My dodgy book only talk about using sed to edit contents of a file not the filename itself.
Cheers
George
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2003 05:58 AM
10-01-2003 05:58 AM
Re: Script help, just to make a change :)
Easy,
#!/usr/bin/sh
ls [0-9][0-9][0-9][0-9]_[0-9][0-9]_[0-9][0-9]_NE:[0-9][0-9].all.cdl | while read X
do
NEWNAME=$(echo ${X} | sed -e 's/.all.cdl$/.txt/' -e 's/://g')
mv ${X} ${NEWNAME}
done
Note the use of the '$' to anchor .all.cdl at the end of the string so that it will not replace the same pattern anywhere else in the string --- although in this case with the restricted ls pattern you couldn't actually get .all.cdl anywhere but at the terminal end of the filename.
A good idea while you are getting your patterns exactly like you want them is to replace (or comment out) the mv command andf replace it with an echo, viz,
echo "${X} ---> ${NEWNAME}"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-01-2003 11:50 AM
10-01-2003 11:50 AM
Re: Script help, just to make a change :)
Cheers Clay