shell脚本,怎么用c实现?

sh/bash/dash/ksh/zsh等Shell脚本
头像
fanhe
帖子: 2357
注册时间: 2007-03-24 23:45

Re: shell脚本,怎么用c实现?

#16

帖子 fanhe » 2012-08-09 10:30

用python吧,简单
过七不候
帖子: 4
注册时间: 2012-07-22 16:35

Re: shell脚本,怎么用c实现?

#17

帖子 过七不候 » 2012-08-19 20:15

不知道这样行不行,
用index函数得到第一个逗号的位置,可以取得文件名
然后用rindex函数得到最后一个点号的位置,可以取得后缀。
再sprintf起来。
头像
lilydjwg
论坛版主
帖子: 4258
注册时间: 2009-04-11 23:46
系统: Arch Linux
联系:

Re: shell脚本,怎么用c实现?

#18

帖子 lilydjwg » 2012-08-19 20:29

过七不候 写了:不知道这样行不行,
用index函数得到第一个逗号的位置,可以取得文件名
然后用rindex函数得到最后一个点号的位置,可以取得后缀。
再sprintf起来。
sprintf??
头像
naturalaw
帖子: 1360
注册时间: 2011-09-06 22:04

Re: shell脚本,怎么用c实现?

#19

帖子 naturalaw » 2012-08-20 3:36

fanhe 写了:用python吧,简单
用python已经实现了。
  • The eternal law
头像
naturalaw
帖子: 1360
注册时间: 2011-09-06 22:04

Re: shell脚本,怎么用c实现?

#20

帖子 naturalaw » 2012-08-20 3:38

lilydjwg 写了:
过七不候 写了:不知道这样行不行,
用index函数得到第一个逗号的位置,可以取得文件名
然后用rindex函数得到最后一个点号的位置,可以取得后缀。
再sprintf起来。
sprintf??
我唯一郁闷的是rename函数的参数必须是常量型的。
  • The eternal law
头像
lilydjwg
论坛版主
帖子: 4258
注册时间: 2009-04-11 23:46
系统: Arch Linux
联系:

Re: shell脚本,怎么用c实现?

#21

帖子 lilydjwg » 2012-08-20 11:30

naturalaw 写了:
lilydjwg 写了:
过七不候 写了:不知道这样行不行,
用index函数得到第一个逗号的位置,可以取得文件名
然后用rindex函数得到最后一个点号的位置,可以取得后缀。
再sprintf起来。
sprintf??
我唯一郁闷的是rename函数的参数必须是常量型的。
「必须是常量型的」?什么意思?
回复