- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- mv on multiple file with joker
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
тАО03-19-2009 04:49 AM
тАО03-19-2009 04:49 AM
Here 400 files like this:
ls *precl*
aa.precl.test
aaprecl.start
precl.bb
rrpreclyy.start
....
I need to rename all this file as this:
aa.prect.test
aaprect.start
prect.bb
rrprectyy.start
...
What is the best way ? Of course the naive command below
mv *prect* *prect*
doesn't work naturally.
Best regards
Den
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2009 05:17 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2009 05:40 AM
тАО03-19-2009 05:40 AM
Re: mv on multiple file with joker
I Don't close this thread immediately in case of some other callback !
Bests Regards
Den
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2009 05:44 AM
тАО03-19-2009 05:44 AM
Re: mv on multiple file with joker
MYSOURCE=prect
MYDEST=precl
for FILE in $(ls *$MYSOURCE*); do NEWFILE=$(echo $FILE| sed 's/$MYSOURCE/$MYDEST/g'); mv $FILE $NEWFILE ; done
Bests Regards
Den
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2009 05:47 AM
тАО03-19-2009 05:47 AM
Re: mv on multiple file with joker
Or, if "$(ls)" causes problems, start with
"find", and do something similar.
bash$ ls -l
total 1
-rw-r----- 1 SMS 40 5 Mar 19 08:41 a b
-rw-r----- 1 SMS 40 5 Mar 19 08:41 c d
bash$ for file in $(ls) ; do echo $file ; done
a
b
c
d
bash$
bash$ find . -type f
./a b
./c d
"$(ls)" could also make the command line too
long.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2009 05:57 AM
тАО03-19-2009 05:57 AM
Re: mv on multiple file with joker
MYSOURCE=prect
MYDEST=precl
for FILE in $(ls *$MYSOURCE*); do NEWFILE=$(echo $FILE| sed 's/'$MYSOURCE'/'$MYDEST'/g'); mv $FILE $NEWFILE ; done
Any comment ? except the find insteaf of ls command.
Bests Regards
Den
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2009 05:58 AM
тАО03-19-2009 05:58 AM
Re: mv on multiple file with joker
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2009 06:18 AM
тАО03-19-2009 06:18 AM
Re: mv on multiple file with joker
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2009 11:47 AM
тАО03-19-2009 11:47 AM
Re: mv on multiple file with joker
Because you're quoting only tiny parts of
the command:
's/'
'/'
'/g'
Not much point in that. The hazards are in
the other parts.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО03-19-2009 11:26 PM
тАО03-19-2009 11:26 PM
Re: mv on multiple file with joker
rename precl prect *
emha.