LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 08-21-2007, 04:32 PM   #1
ouncya
LQ Newbie
 
Registered: Feb 2007
Posts: 20

Rep: Reputation: 0
CAT Command


Hi Friends,

I have created file using CAT command. File name "-r". It accepted. When I tried to see the contents using the command " cat <filename>", I couldn't see. Can any one help me?
 
Old 08-21-2007, 05:17 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 14,834

Rep: Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820
Try "cat -- -r"
And then maybe rename it; use the same trick.
 
Old 08-21-2007, 06:00 PM   #3
ouncya
LQ Newbie
 
Registered: Feb 2007
Posts: 20

Original Poster
Rep: Reputation: 0
hey friend,

Thanks a lot. It's working... :-)
 
Old 08-21-2007, 07:45 PM   #4
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Moral:
don't create files with funny names.

Another trick:
To access a file with a funny name, add the full path. In your example--eg: "cat /home/username/-r". This works for cat, mv, etc.
 
Old 08-21-2007, 08:39 PM   #5
SlowCoder
Member
 
Registered: Oct 2004
Location: Southeast, U.S.A.
Distribution: Fedora (Desktop), CentOS (Server), Knoppix (Diags)
Posts: 934

Rep: Reputation: 38
Quote:
Originally Posted by pixellany View Post
Moral:
don't create files with funny names.

Another trick:
To access a file with a funny name, add the full path. In your example--eg: "cat /home/username/-r". This works for cat, mv, etc.
Pixellany,
Could you also use quotes around the filename, rather than the full path?
 
Old 08-21-2007, 08:50 PM   #6
stress_junkie
Senior Member
 
Registered: Dec 2005
Location: Massachusetts, USA
Distribution: Ubuntu 10.04 and CentOS 5.5
Posts: 3,873

Rep: Reputation: 332Reputation: 332Reputation: 332Reputation: 332
Another way to access files with funny names is to use a GUI file manager.
 
Old 08-21-2007, 09:44 PM   #7
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Quote:
Originally Posted by SlowCoder View Post
Pixellany,
Could you also use quotes around the filename, rather than the full path?
I am fuzzy on this...My comment is based on a situation posted here some months ago. The only solution that I could think of was using the full path.

I think it depends on what funny character gets into the funny filename...let's say you have a character that looks like an option to a command like mv or cp. Quoting won't help--because that only protects the funny character from bash.

Ok, here's one:
touch somedir/-R
This creates the file "-R" in somedir. Now go into somedir and try to make a copy.
 
Old 08-21-2007, 10:47 PM   #8
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
I've found using single quotes works to rm or mv funny named files.
 
Old 08-21-2007, 11:47 PM   #9
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Neither single nor double quotes will work in my example. The key is that "-R" has special meaning to the cp command. any kind of quotes simply serves to insure that the "-R" gets to the cp command without bash interfering.
 
Old 08-24-2007, 11:42 AM   #10
ouncya
LQ Newbie
 
Registered: Feb 2007
Posts: 20

Original Poster
Rep: Reputation: 0
hey friends,

Is there any other way to open the file "-r" rather than "cat -- -r"?
 
Old 08-25-2007, 02:44 AM   #11
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 14,834

Rep: Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820Reputation: 1820
Starting to sound like homework.
 
Old 08-26-2007, 12:48 AM   #12
ouncya
LQ Newbie
 
Registered: Feb 2007
Posts: 20

Original Poster
Rep: Reputation: 0
hey friends,

I found another way.

cat ./-r

It works... :-)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Cat command Option foysol_bgd Linux - Newbie 5 12-11-2008 11:33 AM
Cat and Sed Command Help. vidyashankara Linux - General 22 06-23-2006 02:32 PM
cat command juanb Linux - Newbie 4 08-19-2004 12:14 PM
what are the limits to the 'cat' command? Frybyte Linux - General 12 04-22-2004 05:32 PM
cat Command Moeses Linux - General 1 06-20-2002 04:27 AM


All times are GMT -5. The time now is 04:17 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration