I'm trying to to execute a script, which uses the command rename.

When I execute it, I get a message rename: command not found. Any ideas?

if [[ -z '$3' ]]; then
    shopt -s dotglob
    rename "$EXPRESSION" ./*
    rename "$EXPRESSION" "$3"
  • 3
    sounds to me like rename isn't an installed function anywhere. Or it's not configured in your script properly. As-is, that script doesn't define a functoin called "rename". Further, rename can be a perl package extension for File::Rename and provides a 'newer' interface / command line tool for rename functions
    – Thomas Ward
    Nov 24, 2018 at 21:28
  • 2
    Did you try installing it with sudo apt install rename before running the script?
    – dessert
    Nov 24, 2018 at 22:15

2 Answers 2


I just had to install the rename package.

sudo apt install rename
  • 1
    For the sake of completeness, could you edit to add how you installed it?
    – wjandrea
    Nov 24, 2018 at 22:36
  • @wjandrea edited.
    – paweljvn
    Nov 24, 2018 at 22:38
  • Great. Though it's not a function; it's a file.
    – wjandrea
    Nov 24, 2018 at 22:40
  • @wjandrea I will remember it for the next time. Sorry and thank you.
    – paweljvn
    Nov 24, 2018 at 22:49
  • 2
    Perl rename was installed by default up until, I think 17.04. So earlier posts and guides might assume it was present and not mention this step. On other Linux systems, there is another rename program which works differently also.
    – Zanna
    Dec 15, 2018 at 9:19

My Ubuntu has a man page for rename(1) on fresh install, but running rename gives a CNF error.

The man page style suggests that the command belongs to GNU Core Utilities, but confusingly it actually is rename.ul (Ubuntu Bionic / Disco / Eoan + Debian Buster). This command corresponds to the mysterious rename(1) page.

If you install rename package, the new man page is rename(1p). It's a Perl script, not coreutils.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .