Re: renaming multiple files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Fabio Zyserman wrote:

> I have some files in a directory, called
> prefix-file1
> prefix-file2
> etc
> 
> I want to rename them to
> file1
> file2
> etc
> 
> How can I do it with a bash command?

	for file in prefix-* ; do
	    mv "$file" "${file##prefix-}"
	done

Various utilities exist to perform this task, e.g. rename, mmv, but
none are standard (rename is from util-linux, so it's likely to exist
on most Linux systems, but not other Unices).

-- 
Glynn Clements <glynn@xxxxxxxxxxxxxxxxxx>
-
: send the line "unsubscribe linux-admin" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Newbie]     [Audio]     [Hams]     [Kernel Newbies]     [Util Linux NG]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Device Drivers]     [Samba]     [Video 4 Linux]     [Git]     [Fedora Users]

  Powered by Linux