- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: simplest way to strip a character from a filen...
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
Discussions
Discussions
Forums
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
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
тАО02-21-2006 03:25 PM
тАО02-21-2006 03:25 PM
Re: simplest way to strip a character from a filename
In the script that was processing these files I have changed the line that moves the file to read:
mv $file $(echo "$dest/$file.$dayTimeStr" | tr ":" "_")
(Looking at the script as a whole these days I would have written the whole script in perl which would no doubt have solved a lot of problems and made it a lot easier to maintain.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-21-2006 03:34 PM
тАО02-21-2006 03:34 PM
Re: simplest way to strip a character from a filename
mv $file $(echo "$dest/$file.$dayTimeStr" | tr ":" "_")
It is not good always.
Use as,
mv ${file} $(echo "${dest}/${file}.${dayTimeStr}" | tr ":" "_")
It is good.
PS: Do you want to remove : or change to _ ?
--
Muthu
- Tags:
- sed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-21-2006 03:36 PM
тАО02-21-2006 03:36 PM
Re: simplest way to strip a character from a filename
mv ${file} $(echo ${file}| sed -e 's/://g'
If you want to have SPEED use perl always.
mv ${file} $(echo ${file}| perl -pe 's/://g'
--
Muthu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-21-2006 03:39 PM
тАО02-21-2006 03:39 PM
Re: simplest way to strip a character from a filename
You said, If the whole script was Perl I know you would be right but in this instance the majority of the file handling is done by the shell which invokes perl for every file name. Hence my question about the overhead of "invoking" perl over tr. I had assumed that tr would have less overhead because it is smaller but this is not the only factor.
In the script that was processing these files I have changed the line that moves the file to read:
mv $file $(echo "$dest/$file.$dayTimeStr" | tr ":" "_")
When it comes to handle lot of files, i dont think unix default utilities will play a big part. I am not sure "tr" and "mv" are multithreaded as well. Perl with combination Unix shell utilities is a good way to strike.
-Arun
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-22-2006 03:38 AM
тАО02-22-2006 03:38 AM
Re: simplest way to strip a character from a filename
After careful deliberation, it looks like you need to replace the colon characters and rename the files.
Here's an awk construct that would help. It assumes that your curent working dir is the one that has a guzzillion of those tiny files.
# ls -1 | awk '{x=$0;gsub(":","");system("mv "x" "$0)}'
cheers!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-22-2006 04:47 AM
тАО02-22-2006 04:47 AM
Re: simplest way to strip a character from a filename
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО02-22-2006 11:21 AM
тАО02-22-2006 11:21 AM
Re: simplest way to strip a character from a filename
Thanks for the responses.
I managed to replace the colons in about 90000 file names and fix the script that was responsible for creating them.
Clay, your last post improved my understanding of why it was taking so long a lot.
It did not help that the machine was out of disk space (hence my renaming requirement - I needed to archive the offending files to a Windows environment where colons in file names are verboten.) At one point I was getting errors doing the actual rename because of the lack of disk space.
I would probably still be trying to pull my hair out if if it were not for this forum.
- « Previous
-
- 1
- 2
- Next »