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

时间:2009-05-27 11:16:49

标签: linux macos rename

我读了tutorial,它建议我在util-linux软件包

运行
./configure

我得到了

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

然后建议我在misc-utils

运行以下命令
make rename 

我收到以下警告

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

如何为Mac安装rename -command?

5 个答案:

答案 0 :(得分:3)

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

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

答案 1 :(得分:1)

从linux编译renametutorial中的适应症存在一些细微差别。我使用了文件util-linux-2.22.tar.gz

中的2.22版

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

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

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

然后从那个相同的文件夹,不改成misc-utils,你做make rename

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

答案 2 :(得分:1)

使用Homebrew

轻松安装重命名
brew install rename

答案 3 :(得分:0)

你能不能只使用mv而不是尝试编译rename?甚至可能将其别名为rename

(编辑:忽略我对build-essentials的评论 - as pointed out by yangyang,看起来它应该构建好了无论如何)

答案 4 :(得分:0)

试试这个:

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

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

$rename foo bar *.txt

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

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