![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Can I know find syntax to find given date files | bache_gowda | Shell Programming and Scripting | 3 | 03-26-2008 02:37 AM |
| Little bit weired : Find files in UNIX w/o using find or where command | jatin.jain | Shell Programming and Scripting | 10 | 09-19-2007 03:47 AM |
| how to find a file named vijay in a directory using find command | amirthraj_12 | UNIX for Dummies Questions & Answers | 5 | 10-25-2006 02:39 PM |
| Find files older than 20 days & not use find | halo98 | Shell Programming and Scripting | 2 | 05-18-2006 11:19 AM |
| command find returned bash: /usr/bin/find: Argument list too long | yacsil | Shell Programming and Scripting | 1 | 12-15-2003 02:38 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
find and mv files in single line
I have a.txt and b.txt (and so on ) in a directory.
I need to move these files to a.xml , b.xml and so on, basically I just need to rename all the XXX.txt files to XXX.xml using find and mv , how can we do it? something like below, but it is not right find . -name '*.txt' -exec mv {}\.xml \; Any ideas? Thanks Muru Last edited by muru; 06-29-2006 at 03:05 PM. |
| Forum Sponsor | ||
|
|
|
|||
|
If you have the mmv command, you can just do
Code:
mmv '[ab].txt' '#1.xml' |
|
|||
|
Thanks for your reply, unfortunately SunOs 5.7 doesn't seem to have mmv.
is there any way we could achieve this by following pseudo find mv [the file given by find to] ["work on the result of find to cut just the file name without extension" and add our extension (ie .xml)] instead using cut and appening the .xml, could we use sed to replace extension to .xml and move the original file to this name? I am sorry if this is not achievable. Thanks Muru |
|
|||
|
Thanks for the reply, both the above suggestions works.
Can we do it in a single line using something like this for file in `ls *.txt` ;do mv $file `sed 's/\..*$/.txt/'`;done this doesn;t work, but I feel that this may work with minor tweaks. Thanks again for the reply! |