亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

Chinaunix

標(biāo)題: 怎么改變文件的后綴名 [打印本頁(yè)]

作者: happyman1    時(shí)間: 2003-12-05 15:05
標(biāo)題: 怎么改變文件的后綴名
我有幾個(gè)文件,他們的后綴名都是".old",如下:
#ls -al
-rwx--xr--     .. .. .. .. ..     file1.old
-rwx--xr--     .. .. .. .. ..     file2.old
-rwx--xr--     .. .. .. .. ..     file3.old
-rwx--xr--     .. .. .. .. ..     file4.old
請(qǐng)問(wèn):如何可以把這些文件的后綴全改為".new",如下:
-rwx--xr--     .. .. .. .. ..     file1.new
-rwx--xr--     .. .. .. .. ..     file2.new
-rwx--xr--     .. .. .. .. ..     file3.new
-rwx--xr--     .. .. .. .. ..     file4.new

(不知道用basename可不可以,試了不成功)
作者: c1l2d3    時(shí)間: 2003-12-05 15:19
標(biāo)題: 怎么改變文件的后綴名
for i in `ls *.old`
do
new=`echo $i | sed 's/\.old//g'`
mv $i $new".new"
done
作者: 西方失敗    時(shí)間: 2003-12-05 15:48
標(biāo)題: 怎么改變文件的后綴名
可以直接在此目錄下
for i in *.old
do
new=`echo $i | sed 's/\.old//g'`
mv $i $new".new"
done
作者: admirer    時(shí)間: 2003-12-05 16:30
標(biāo)題: 怎么改變文件的后綴名
  1. for i in *.old;do  mv $i ${i%.old}.new ;done
復(fù)制代碼

作者: c1l2d3    時(shí)間: 2003-12-05 16:35
標(biāo)題: 怎么改變文件的后綴名
[quote]原帖由 "admirer"][/quote 發(fā)表:


版主的總是很精妙,偶總是看不大懂。羨慕ing
作者: 大紅機(jī)器    時(shí)間: 2003-12-05 17:25
標(biāo)題: 怎么改變文件的后綴名
俺也不懂,解釋下好嗎?
作者: admirer    時(shí)間: 2003-12-05 17:41
標(biāo)題: 怎么改變文件的后綴名
[quote]原帖由 "大紅機(jī)器"]俺也不懂,解釋下好嗎?[/quote 發(fā)表:

分開(kāi)看就好理解了:
1:${i%.old}表示從變量i的末尾(如果有的話)去掉“.old”
2:${i%.old}.new去掉i的后綴“.old”后再加上“.new”
3:mv $i  ${i%.old}.new  明白了?
另:
${var#string}表示從變量首部去掉sting
作者: 大紅機(jī)器    時(shí)間: 2003-12-05 17:52
標(biāo)題: 怎么改變文件的后綴名
這里%算是個(gè)運(yùn)算符嗎?還有什么類(lèi)似這樣的運(yùn)算嗎?
查書(shū)都不知道查那章   
作者: c1l2d3    時(shí)間: 2003-12-05 20:19
標(biāo)題: 怎么改變文件的后綴名
版主給發(fā)點(diǎn)這樣的資料吧!
作者: bjgirl    時(shí)間: 2003-12-05 20:47
標(biāo)題: 怎么改變文件的后綴名
這樣的問(wèn)題,還是多瀏覽瀏覽論壇里的貼子再問(wèn)!
作者: r2007    時(shí)間: 2003-12-05 22:08
標(biāo)題: 怎么改變文件的后綴名
吐血推薦兩篇精品文章,我的shell和text tools知識(shí)全靠這兩篇文章。

http://www.tldp.org/LDP/abs/abs-guide.pdf
http://www.student.northpark.edu/pemente/sed/sed1line.txt
作者: 網(wǎng)中人    時(shí)間: 2003-12-06 00:50
標(biāo)題: 怎么改變文件的后綴名
[quote]原帖由 "c1l2d3"]版主給發(fā)點(diǎn)這樣的資料吧![/quote 發(fā)表:

有人發(fā)過(guò)了...(只是一般人沒(méi)去挖而已)...  ^_^
http://72891.cn/forum/viewtopic.php?t=201843

回樓主:
若,系統(tǒng)上找得到 rename 這個(gè)工具(linux 一般都有),試試:
$ rename .old .new *.old
作者: iamok    時(shí)間: 2003-12-06 01:52
標(biāo)題: 怎么改變文件的后綴名
原帖由 "r2007" 發(fā)表:
吐血推薦兩篇精品文章,我的shell和text tools知識(shí)全靠這兩篇文章。

http://www.tldp.org/LDP/abs/abs-guide.pdf
http://www.student.northpark.edu/pemente/sed/sed1line.txt



好書(shū)啊....thx..
作者: gunguymadman007    時(shí)間: 2003-12-12 10:05
標(biāo)題: 怎么改變文件的后綴名
[quote]原帖由 "admirer"]for i in *.old;do  mv $i ${i%.old}.new ;done[/quote 發(fā)表:
我再問(wèn)一下,i所代表的是*么,還是帶有.old的全部名字?
作者: admirer    時(shí)間: 2003-12-12 17:42
標(biāo)題: 怎么改變文件的后綴名
[quote]原帖由 "gunguymadman007"]以儻室幌攏琲所代表的是*么,還是帶有.old的全部名字?[/quote 發(fā)表:

i 代表的是所有.old文件的集合中的一個(gè),for負(fù)責(zé)將這個(gè)集合中的所有文件逐個(gè)分配給i,并由循環(huán)體逐一處理。
作者: admirer    時(shí)間: 2003-12-13 23:11
標(biāo)題: 怎么改變文件的后綴名
原帖由 "c1l2d3"]版主給發(fā)點(diǎn)這樣的資料吧![/quote 發(fā)表:

[quote]Variable Expansion Formats
${#variable} length of variable
${variable:-word} value of variable if set and not null,else print word
${variable:=word} value of variable if set and not null,else variable is set to word, then expanded
${variable:+word}value of word if variable is set and not null, else nothing is substituted
${variable} value of variable if set and not null,else print "variable: parameter null or not set"
${variableword}value of variable if set and not null,else print value of word and exit
${variable#pattern}value of variable without the smallest beginning portion that matches pattern
${variable##pattern}value of variable without the largest beginning portion that matches pattern
${variable%pattern}value of variable without the smallest ending portion that matches pattern
${variable%%pattern}value of variable without the largest ending portion that matches pattern
${variable//pattern1/pattern2}replace all occurrences of pattern1 with pattern2 in variable





歡迎光臨 Chinaunix (http://72891.cn/) Powered by Discuz! X3.2