LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-22-2012, 11:59 PM   #1
vicky007aggrwal
Member
 
Registered: Aug 2012
Posts: 95

Rep: Reputation: Disabled
special character in file name


I have very odd requirement in which i need to create a file name havog special character i.e / (forward slash) in file, does anyone know how to do it ???

eg:
cp report.xml nov/report.xml


above command throws error, i want to copy file having forward slash in its name

please suggest
 
Old 11-23-2012, 12:01 AM   #2
TobiSGD
Moderator
 
Registered: Dec 2009
Location: Germany
Distribution: Whatever fits the task best
Posts: 17,148
Blog Entries: 2

Rep: Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886Reputation: 4886
You have to escape the special characters you want to use, in your example:
Code:
cp report.xml nov\/report.xml
http://tldp.org/LDP/Bash-Beginners-G...ect_03_03.html
 
Old 11-23-2012, 12:05 AM   #3
vicky007aggrwal
Member
 
Registered: Aug 2012
Posts: 95

Original Poster
Rep: Reputation: Disabled
Thanks Tobi SGD , but that doesnt work. I got below error


cp report.xml nov\/report.xml
cp:cannot create regular file 'nov/report.xml' : no such file or director"
 
Old 11-23-2012, 12:08 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Not allowed
Quote:
In Unix-like file systems the null character, as that is the end-of-string indicator[14] and the path separator / are prohibited.
https://en.wikipedia.org/wiki/Filena...ters_and_words

[14] ref
Quote:
3.169 Filename

A name consisting of 1 to {NAME_MAX} bytes used to name a file. The characters composing the name may be selected from the set of all character values excluding the slash character and the null byte. The filenames dot and dot-dot have special meaning. A filename is sometimes referred to as a "pathname component".
http://pubs.opengroup.org/onlinepubs...tml#tag_03_169
 
2 members found this post helpful.
Old 11-23-2012, 12:29 AM   #5
vicky007aggrwal
Member
 
Registered: Aug 2012
Posts: 95

Original Poster
Rep: Reputation: Disabled
That means i cannot have forward slash in filename
 
Old 11-23-2012, 02:10 AM   #6
vicky007aggrwal
Member
 
Registered: Aug 2012
Posts: 95

Original Poster
Rep: Reputation: Disabled
Thanks chrism01 , for responding ..
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
block special and character special files s_shenbaga Linux - Newbie 4 06-23-2015 02:16 AM
Find and Replace character/special character from the file MyRelam Red Hat 8 05-21-2012 12:52 AM
special character tostay2003 Programming 5 01-06-2009 12:39 PM
BASH: Truncating file names with special character tboss888 Programming 2 12-18-2008 07:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration