如何添加文件.txt到现存的档案拱形,但在某种程度上拱形将仅包含文件.txt? 我使用下面的命令,但是拱形已更新,并且也包含旧文件。我没有看到可以执行此操作的开关。
rar a arch.rar file.txt
答案1
这没有任何意义;)但你可以做这样的事情:
$ FILE2UPD=file.2; RARCH=arch.rar && for i in `rar l $RARCH | grep -v $FILE2UPD | tail -n +9 | head -n -3 | cut -f2 -d' '`; do rar d $RARCH $i; done && rar u $RARCH $FILE2UPD
例子:
$ cat file.1
test 1
$ cat file.2
test 2
$ cat file.3
test 3
$ rar a arch.rar file.*
RAR 3.93 Copyright (c) 1993-2010 Alexander Roshal 15 Mar 2010
Shareware version Type RAR -? for help
Evaluation copy. Please register.
Creating archive arch.rar
Adding file.1 OK
Adding file.2 OK
Adding file.3 OK
Done
$ echo "test4" > file.2
$ cat file.2
test4
$ FILE2UPD=file.2; RARCH=arch.rar && for i in `rar l $RARCH | grep -v $FILE2UPD | tail -n +9 | head -n -3 | cut -f2 -d' '`; do rar d $RARCH $i; done && rar u $RARCH $FILE2UPD
RAR 3.93 Copyright (c) 1993-2010 Alexander Roshal 15 Mar 2010
Shareware version Type RAR -? for help
Deleting from arch.rar
Deleting file.1
Done
RAR 3.93 Copyright (c) 1993-2010 Alexander Roshal 15 Mar 2010
Shareware version Type RAR -? for help
Deleting from arch.rar
Deleting file.3
Done
RAR 3.93 Copyright (c) 1993-2010 Alexander Roshal 15 Mar 2010
Shareware version Type RAR -? for help
Evaluation copy. Please register.
Updating archive arch.rar
Updating file.2 OK
Done
$ rar l arch.rar
RAR 3.93 Copyright (c) 1993-2010 Alexander Roshal 15 Mar 2010
Shareware version Type RAR -? for help
Archive arch.rar
Name Size Packed Ratio Date Time Attr CRC Meth Ver
-------------------------------------------------------------------------------
file.2 6 16 266% 04-03-11 12:45 -rw-r--r-- 012EC35E m3b 2.9
-------------------------------------------------------------------------------
1 6 16 266%
$ rm file.*
$ rar e arch.rar
RAR 3.93 Copyright (c) 1993-2010 Alexander Roshal 15 Mar 2010
Shareware version Type RAR -? for help
Extracting from arch.rar
Extracting file.2 OK
All OK
$ cat file.2
test4