无法将Linux的重命名安装到Mac

时间:2021-10-10 01:29:16

I read the tutorial which advises me to run at util-linux package

我阅读了教程,建议我在util-linux包中运行

./configure

I get

configuring util-linux-2.12q

You don't have <scsi/scsi.h>
You don't have <linux/blkpg.h>
You don't have <linux/kd.h>
You have <locale.h>You have <langinfo.h>
You have <sys/user.h>
You have <uuid/uuid.h>
You have <rpcsvc/nfs_prot.h>
You don't have <asm/types.h>
You don't have <linux/raw.h>
You have <stdint.h>
You don't have <sys/io.h>
You have inet_aton()
You have fsync()
You have getdomainname()
You have nanosleep()
You don't have personality()
You don't have updwtmp()
You have fseeko()
You have lchown()
You don't have rpmatch()
You have <term.h>
You have ncurses. Using <ncurses.h>.
You have termcap
You don't need -lcrypt
Strange... Static compilation fails here.
You don't have native language support
You have __progname
You don't have <pty.h> and openpty()
You have wide character support
You don't have SYS_pivot_root
You have a tm_gmtoff field in struct tm
Your rpcgen output does not compile - using pregenerated code
You have zlib
You don't have blkid

It then advises me to run the following command at misc-utils

然后它建议我在misc-utils上运行以下命令

make rename 

I get the following warning

我收到以下警告

cc -pipe -O2 -mtune=i386 -fomit-frame-pointer -I../lib -Wall -Wmissing-prototypes -Wstrict-prototypes -DNCH=1   -D_FILE_OFFSET_BITS=64 -DSBINDIR=\"/sbin\" -DUSRSBINDIR=\"/usr/sbin\" -DLOGDIR=\"/var/log\" -DVARPATH=\"/var\" -DLOCALEDIR=\"/usr/share/locale\" -O2  -s  rename.c   -o rename
ld warning: option -s is obsolete and being ignored

How can you install rename -command for Mac?

如何为Mac安装rename -command?

5 个解决方案

#1


That's a warning, not an error.

这是一个警告,而不是错误。

I've just tried this myself and it has built a rename executable.

我自己尝试了这个,它已经构建了一个重命名可执行文件。

#2


Do compile rename from linux. There are some minor differences to the indications in the tutorial. I used version 2.22 from the file util-linux-2.22.tar.gz

从linux编译重命名。本教程中的指示存在一些细微差别。我使用了文件util-linux-2.22.tar.gz中的2.22版

Download it and uncompress it. Go to the uncompressed folder in a terminal.

下载并解压缩。转到终端中的未压缩文件夹。

Don't just run ./configure, use this command with flags instead:

不要只运行./configure,而是使用带有flags的命令:

./configure --disable-su --disable-sulogin --disable-login

./configure --disable-su --disable-sulogin --disable-login

then from that very same folder, NOT changing into misc-utils, you do make rename

然后从那个相同的文件夹,不改为misc-utils,你做重命名

That's all, in the current folder you'll have the executable and in the misc-utils the man documentation if you need it.

就是这样,在当前文件夹中,您将拥有可执行文件,如果需要,可以在misc-utils中获取man文档。

#3


Easily install rename using Homebrew

使用Homebrew轻松安装重命名

brew install rename

#4


Can you not just use mv instead of trying to compile rename? Maybe even alias it to rename?

你能不能只使用mv而不是尝试编译重命名?也许甚至别名重命名?

(EDIT: Ignore my comment about build-essentials - as pointed out by yangyang, it looks like it should have built ok anyhow)

(编辑:忽略我对build-essentials的评论 - 正如yangyang指出的那样,无论如何它看起来应该已经构建好了)

#5


Try this:

function rename { from=$1; to=$2; shift 2; for i in "$@"; do j=`echo $i | sed "s/$from/$to/"`; mv "$i" "$j"; done }

Paste it into your .profile or .bashrc and run it just like the Red Hat rename utility:

将其粘贴到.profile或.bashrc中并像Red Hat重命名实用程序一样运行它:

$rename foo bar *.txt

Turns foo1.txt, foo2.txt and foofoo.txt into bar1.txt, bar2.txt but, somewhat irritatingly, barfoo.txt.
Maybe someone can tweak it to fix this.

把foo1.txt,foo2.txt和foofoo.txt变成了bar1.txt,bar2.txt,但是有点恼火,barfoo.txt。也许有人可以调整它来解决这个问题。

Test it by putting 'echo' before 'mv' so that it outputs a list of all changes it will make without making them.

通过在'mv'之前放置'echo'来测试它,以便它输出一个列表,列出它将在不制作它们的情况下进行的所有更改。

#1


That's a warning, not an error.

这是一个警告,而不是错误。

I've just tried this myself and it has built a rename executable.

我自己尝试了这个,它已经构建了一个重命名可执行文件。

#2


Do compile rename from linux. There are some minor differences to the indications in the tutorial. I used version 2.22 from the file util-linux-2.22.tar.gz

从linux编译重命名。本教程中的指示存在一些细微差别。我使用了文件util-linux-2.22.tar.gz中的2.22版

Download it and uncompress it. Go to the uncompressed folder in a terminal.

下载并解压缩。转到终端中的未压缩文件夹。

Don't just run ./configure, use this command with flags instead:

不要只运行./configure,而是使用带有flags的命令:

./configure --disable-su --disable-sulogin --disable-login

./configure --disable-su --disable-sulogin --disable-login

then from that very same folder, NOT changing into misc-utils, you do make rename

然后从那个相同的文件夹,不改为misc-utils,你做重命名

That's all, in the current folder you'll have the executable and in the misc-utils the man documentation if you need it.

就是这样,在当前文件夹中,您将拥有可执行文件,如果需要,可以在misc-utils中获取man文档。

#3


Easily install rename using Homebrew

使用Homebrew轻松安装重命名

brew install rename

#4


Can you not just use mv instead of trying to compile rename? Maybe even alias it to rename?

你能不能只使用mv而不是尝试编译重命名?也许甚至别名重命名?

(EDIT: Ignore my comment about build-essentials - as pointed out by yangyang, it looks like it should have built ok anyhow)

(编辑:忽略我对build-essentials的评论 - 正如yangyang指出的那样,无论如何它看起来应该已经构建好了)

#5


Try this:

function rename { from=$1; to=$2; shift 2; for i in "$@"; do j=`echo $i | sed "s/$from/$to/"`; mv "$i" "$j"; done }

Paste it into your .profile or .bashrc and run it just like the Red Hat rename utility:

将其粘贴到.profile或.bashrc中并像Red Hat重命名实用程序一样运行它:

$rename foo bar *.txt

Turns foo1.txt, foo2.txt and foofoo.txt into bar1.txt, bar2.txt but, somewhat irritatingly, barfoo.txt.
Maybe someone can tweak it to fix this.

把foo1.txt,foo2.txt和foofoo.txt变成了bar1.txt,bar2.txt,但是有点恼火,barfoo.txt。也许有人可以调整它来解决这个问题。

Test it by putting 'echo' before 'mv' so that it outputs a list of all changes it will make without making them.

通过在'mv'之前放置'echo'来测试它,以便它输出一个列表,列出它将在不制作它们的情况下进行的所有更改。