由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 问个Unix的问题
相关主题
phone interview问个amazon的题,关于url的提取
关于技能规划,发包子求指点问个Unix的面试题目
一道题问个unix命令问题
Linux 面试题目(付答案)收集分享问个临时抱佛脚的问题
Production support Position (Unix, Java, Perl and shell scripting)问个unix难题,新手勿入
please help for an Unix shell problem问个onsite interview 时的称呼问题
碰到一个非常奇怪的情况。 (转载)问个sql问题
代发amazon面井问个称呼问题
相关话题的讨论汇总
话题: txt话题: unix话题: named话题: use话题: what
进入JobHunting版参与讨论
1 (共1页)
h********0
发帖数: 440
1
In a directory, I have hundreds of files named like "a_*.txt"
now I want to change them to be named like "b_*.txt"
What Unix command can I use?
Thanks.
r********g
发帖数: 1351
2
I don't know if you can use rename:
rename a b a_*.txt
I tried on linux, and it works.

【在 h********0 的大作中提到】
: In a directory, I have hundreds of files named like "a_*.txt"
: now I want to change them to be named like "b_*.txt"
: What Unix command can I use?
: Thanks.

f******g
发帖数: 13917
3
这儿有一个小程序,测试过的。
for file in a_*.txt
do
mv ${file} $(echo ${file} | sed 's/a\(.*\)/b\1/')
done

【在 h********0 的大作中提到】
: In a directory, I have hundreds of files named like "a_*.txt"
: now I want to change them to be named like "b_*.txt"
: What Unix command can I use?
: Thanks.

h********0
发帖数: 440
4
Thanks very much freelong.
Yes. That's something similar to what I am looking for.
I thought to use sed, but I am not very familiar with it.
If there any other easier way I can do this?

【在 f******g 的大作中提到】
: 这儿有一个小程序,测试过的。
: for file in a_*.txt
: do
: mv ${file} $(echo ${file} | sed 's/a\(.*\)/b\1/')
: done

L***s
发帖数: 2944
5
I think this is the pretty easy way.
however, you can use PERL.

【在 h********0 的大作中提到】
: Thanks very much freelong.
: Yes. That's something similar to what I am looking for.
: I thought to use sed, but I am not very familiar with it.
: If there any other easier way I can do this?

h********0
发帖数: 440
6
Thanks Lukas.
I never used perl~~
So, I will adopt freelong's code.

【在 L***s 的大作中提到】
: I think this is the pretty easy way.
: however, you can use PERL.

w******p
发帖数: 166
7
u can do it w/o using sed:
for f in $(ls a_*) do; echo mv $f b_${f#*_}; done
verify that the mv commands prints ok, then remove the "echo" to do the real
thing
h********0
发帖数: 440
8
cool, thank you, westcamp.
1 (共1页)
进入JobHunting版参与讨论
相关主题
问个称呼问题Production support Position (Unix, Java, Perl and shell scripting)
求教一个SQL的问题please help for an Unix shell problem
{0xFACEB00C>>2 in decimal}@fb.com到底是啥?碰到一个非常奇怪的情况。 (转载)
[合集] 今天google面试的一个问题代发amazon面井
phone interview问个amazon的题,关于url的提取
关于技能规划,发包子求指点问个Unix的面试题目
一道题问个unix命令问题
Linux 面试题目(付答案)收集分享问个临时抱佛脚的问题
相关话题的讨论汇总
话题: txt话题: unix话题: named话题: use话题: what