ITPub博客

首页 > 数据库 > Oracle > [20210929]带有回车的文件如何改名.txt

[20210929]带有回车的文件如何改名.txt

原创 Oracle 作者:lfree 时间:2021-09-29 09:15:27 0 删除 编辑

[20210929]带有回车的文件如何改名.txt

--//http://www.itpub.net/thread-2143182-1-1.html,里面涉及到redo log文件该有换行符号,涉及到改名问题,
--//当然作者采用删除再重建也是可以的,测试看看遇到这样的情况如何改名.

$ mkdir Testz
$ cd Testz

$ touch "aaa^Jbbb"
--//^J 通过ctrl+v ctrl+J输入. 这样就建立带有\n字符的文件

$ ls -1 | xxd -c 16
0000000: 6161 610a 6262 620a                      aaa.bbb.

--//0x0a 代表\n.

--//改名很简单.

 $ mv aaa?bbb aaa
`aaa\nbbb' -> `aaa'

$ ls -1 |xxd -c 16
0000000: 6161 610a                                aaa.

--//这样就修改成没有回车换行的文件了.其它方法.

$ mv aaa aaa^Jbbb
/bin/mv: `aaa' and `aaa' are the same file
-bash: bbb: command not found

--//^_^,这样写变成了 mv aaa aaa bbb,加上引号ok.

$ mv aaa "aaa^Jbbb"
`aaa' -> `aaa\nbbb'

$ mv "aaa^Jbbb" aaa
`aaa\nbbb' -> `aaa'

--//在测试环境测试看看.
SYS@book> startup mount
ORACLE instance started.
Total System Global Area  643084288 bytes
Fixed Size                  2255872 bytes
Variable Size             205521920 bytes
Database Buffers          427819008 bytes
Redo Buffers                7487488 bytes
Database mounted.

SYS@book> @ logfile
GROUP# STATUS     TYPE       MEMBER                          IS_ GROUP# THREAD# SEQUENCE#       BYTES BLOCKSIZE MEMBERS ARC STATUS     FIRST_CHANGE# FIRST_TIME          NEXT_CHANGE# NEXT_TIME
------ ---------- ---------- ------------------------------- --- ------ ------- --------- ----------- --------- ------- --- ---------- ------------- ------------------- ------------ -------------------
     1            ONLINE     /mnt/ramdisk/book/redo01.log    NO       1       1      1346    52428800       512       1 YES INACTIVE     15026404702 2021-09-28 09:35:56  15026411573 2021-09-28 11:00:59
     2            ONLINE     /mnt/ramdisk/book/redo02.log    NO       2       1      1347    52428800       512       1 NO  CURRENT      15026411573 2021-09-28 11:00:59 2.814750E+14
     3            ONLINE     /mnt/ramdisk/book/redo03.log    NO       3       1      1345    52428800       512       1 YES INACTIVE     15026396123 2021-09-26 10:32:23  15026404702 2021-09-28 09:35:56
     4            STANDBY    /mnt/ramdisk/book/redostb01.log NO
     5            STANDBY    /mnt/ramdisk/book/redostb02.log NO
     6            STANDBY    /mnt/ramdisk/book/redostb03.log NO
     7            STANDBY    /mnt/ramdisk/book/redostb04.log NO
7 rows selected.

$ cd /mnt/ramdisk/book/
$ mv redo03.log "redo^J03.log"
`redo03.log' -> `redo\n03.log'

$ ll -b redo*
-rw-r----- 1 oracle oinstall 52429312 2021-09-29 09:01:13 redo01.log
-rw-r----- 1 oracle oinstall 52429312 2021-09-29 09:02:59 redo02.log
-rw-r----- 1 oracle oinstall 52429312 2021-09-29 09:01:13 redo\n03.log
-rw-r----- 1 oracle oinstall 52429312 2021-02-25 09:51:41 redostb01.log
-rw-r----- 1 oracle oinstall 52429312 2021-02-25 09:51:41 redostb02.log
-rw-r----- 1 oracle oinstall 52429312 2021-02-25 09:51:41 redostb03.log
-rw-r----- 1 oracle oinstall 52429312 2021-02-25 09:51:41 redostb04.log


SYS@book> alter database rename file '/mnt/ramdisk/book/redo03.log' to '/mnt/ramdisk/book/redo
  2  03.log';
Database altered.

SYS@book> @ logfile
GROUP# STATUS     TYPE       MEMBER                           IS_ GROUP# THREAD# SEQUENCE#       BYTES BLOCKSIZE MEMBERS ARC STATUS     FIRST_CHANGE# FIRST_TIME          NEXT_CHANGE# NEXT_TIME
------ ---------- ---------- -------------------------------- --- ------ ------- --------- ----------- --------- ------- --- ---------- ------------- ------------------- ------------ -------------------
     1            ONLINE     /mnt/ramdisk/book/redo01.log     NO       1       1      1346    52428800       512       1 YES INACTIVE     15026404702 2021-09-28 09:35:56  15026411573 2021-09-28 11:00:59
     2            ONLINE     /mnt/ramdisk/book/redo02.log     NO       2       1      1347    52428800       512       1 NO  CURRENT      15026411573 2021-09-28 11:00:59 2.814750E+14
     3            ONLINE     /mnt/ramdisk/book/redo           NO       3       1      1345    52428800       512       1 YES INACTIVE     15026396123 2021-09-26 10:32:23  15026404702 2021-09-28 09:35:56
                             03.log
     4            STANDBY    /mnt/ramdisk/book/redostb01.log  NO
     5            STANDBY    /mnt/ramdisk/book/redostb02.log  NO
     6            STANDBY    /mnt/ramdisk/book/redostb03.log  NO
     7            STANDBY    /mnt/ramdisk/book/redostb04.log  NO
7 rows selected.

--//能改成带有\n的字符,再改回去应该很简单了.
$ mv "redo^J03.log" redo03.log
`redo\n03.log' -> `redo03.log'

SYS@book> alter database rename file '/mnt/ramdisk/book/redo
  2  03.log' to '/mnt/ramdisk/book/redo03.log';
Database altered.

SYS@book> @ logfile
GROUP# STATUS     TYPE       MEMBER                          IS_ GROUP# THREAD# SEQUENCE#       BYTES BLOCKSIZE MEMBERS ARC STATUS     FIRST_CHANGE# FIRST_TIME          NEXT_CHANGE# NEXT_TIME
------ ---------- ---------- ------------------------------- --- ------ ------- --------- ----------- --------- ------- --- ---------- ------------- ------------------- ------------ -------------------
     1            ONLINE     /mnt/ramdisk/book/redo01.log    NO       1       1      1346    52428800       512       1 YES INACTIVE     15026404702 2021-09-28 09:35:56  15026411573 2021-09-28 11:00:59
     2            ONLINE     /mnt/ramdisk/book/redo02.log    NO       2       1      1347    52428800       512       1 NO  CURRENT      15026411573 2021-09-28 11:00:59 2.814750E+14
     3            ONLINE     /mnt/ramdisk/book/redo03.log    NO       3       1      1345    52428800       512       1 YES INACTIVE     15026396123 2021-09-26 10:32:23  15026404702 2021-09-28 09:35:56
     4            STANDBY    /mnt/ramdisk/book/redostb01.log NO
     5            STANDBY    /mnt/ramdisk/book/redostb02.log NO
     6            STANDBY    /mnt/ramdisk/book/redostb03.log NO
     7            STANDBY    /mnt/ramdisk/book/redostb04.log NO
7 rows selected.

$ ls -l redo0*
-rw-r----- 1 oracle oinstall 52429312 2021-09-29 09:01:13 redo01.log
-rw-r----- 1 oracle oinstall 52429312 2021-09-29 09:02:59 redo02.log
-rw-r----- 1 oracle oinstall 52429312 2021-09-29 09:01:13 redo03.log

SYS@book> alter database open ;
Database altered.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/267265/viewspace-2794303/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    3081
  • 访问量
    6806311