Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File name with a carriage return 2

Status
Not open for further replies.

SJSFoxPro

Technical User
Jun 19, 2003
110
US
I have an Oracle data file name with a carriage return. I need to copy the file to a "correct" name (no carriage return) and then remove the "incorrect" file.

Can anyone help me with how to issue a cp and rm command with the carriage return in it to avoid the "not found" message?
 
So long as you can identify a wildcard pattern which only matches that file, then this should work.

[tt]mv [blue]file*[/blue] newfile[/tt]

Experiment with different patterns in
[tt]ls -l [blue]file*[/blue][/tt]
until only the file you want to rename is printed.


--
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
 
if the embedded character is a carriage_return:
mv 'filename_with^Mcharacter' 'filename_without'

or

if the embedded character is e newline character:
mv 'filename_with^Jcharacter' 'filename_without'

The trick is in using ctrl-Vctrl-J or ctrl-Vctrl-M to quote the control character in your command line and to use quotes around the tricky filename'

After you type the ctrl-V lead-in character, the next control character is embedded in your command line and looses its special meaning.


HTH,

p5wizard
 
use its inode:

In the directory where the file is located:

ls -il *

Note the inode (first column) of the file. Then (still in the directory where the file is):

find ./ -inum <the files inode> -exec mv {} <some new file.name> \;


The methods in the aboves posts will work too - pick your favorite method and enjoy.
 
It worries me slightly that this in an Oracle data file. I take it you are closing the database before doing the move? I'm not entirely certain, but presumably you would also need to make some changes to the database itself if it is seeing it as a datafile with a carriage return included in it's name, perhaps using an alter database rename file .... command.

Alan Bennett said:
I don't mind people who aren't what they seem. I just wish they'd make their mind up.
 
I’m back to document my solution for future readers (I don’t like to leave a question hanging.)

I my case, I chose sbrews suggestion. Although, the other suggestions also seemed feasible and I appreciate everyone’s input.

Here are all the commands I used to correct the datafile with the carriage return in the file name (after placing the database in restricted mode):

-- **** find file <inode> in UNIX ****
$ ls -il *
8 -rw-r----- 1 oracle10 dba 146874368 Jan 30 07:05 b
vrdd01.dbf
9 -rw-r----- 1 oracle10 dba 262217728 Jan 30 07:05 bvrdd02.dbf
10 -rw-r----- 1 oracle10 dba 183574528 Jan 30 08:58 bvrdd03.dbf
11 -rw-r----- 1 oracle10 dba 125902848 Jan 30 07:05 bvrdd04.dbf

-- **** cp file in UNIX ****
$ find ./ -inum 8 -exec cp {} bvrdd01.dbf \;

-- **** vary OFFLINE in SQLPlus ****
alter tablespace BVRDD01 offline;
alter database datafile '/vg08lvol2/oradata/vital/b
vrdd01.dbf' offline;

-- **** RENAME datafile for tablespace in SQLPlus ****
--alter tablespace BVRDD01 rename datafile
-- '/vg08lvol2/oradata/vital/b
--vrdd01.dbf'
-- to '/vg08lvol2/oradata/vital/bvrdd01.dbf';

-- **** vary ONLINE in SQLPlus ****
--alter database datafile '/vg08lvol2/oradata/vital/bvrdd01.dbf' online;
--alter tablespace BVRDD01 online;

-- **** rm file with carriage return in UNIX ****
$ find ./ -inum 8 -exec rm {} \;
 
Thanks for posting your complete solution. Only thing I would have done differently is: I would have copied the file after taking the TS and file offline. But seeing as you had the DB in restricted mode, I'm sure you'll be fine.


HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top