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 10-29-2003, 09:12 AM   #1
ergo_sum
Member
 
Registered: Aug 2003
Posts: 253

Rep: Reputation: 30
re: how do I open file from command line


Oh the shame of it!!

How do I open grub.conf from the command line? I know how to cd there (cd /etc), but don't know how to open the file from the prompt. Too dependent on gui.

Thanks,

ergo_sum
 
Old 10-29-2003, 09:14 AM   #2
aus9
Guru
 
Registered: Oct 2003
Posts: 5,056

Rep: Reputation: Disabled
i use mdk, to read but not edit

cat /directory/filename

to edit read the vim tutorial or man vim etc

vim /directory/filename
 
Old 10-29-2003, 09:15 AM   #3
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
You need to use an editor like vi, emacs,joe, jove (there are plenty)

General syntax (vi can be substituted with any editor you choose):

$ vi <file-to-edit>
 
Old 10-29-2003, 09:45 AM   #4
lenlutz
Member
 
Registered: May 2003
Location: philadelhpia pa
Posts: 92

Rep: Reputation: 15
if you only need to VIEW the file
theres more (may be linked to pg too)

more file_name
 
Old 10-29-2003, 10:32 AM   #5
ergo_sum
Member
 
Registered: Aug 2003
Posts: 253

Original Poster
Rep: Reputation: 30
Thanks all.

ergo_sum
 
Old 10-29-2003, 10:33 AM   #6
ergo_sum
Member
 
Registered: Aug 2003
Posts: 253

Original Poster
Rep: Reputation: 30
PS:

Can I edit a file through 'cat'?
Command line access was because I had to su to get there, and I didn't want to log-off and then log-on as root.

ergo_sum
 
Old 10-29-2003, 11:23 AM   #7
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Yeah - cat > file
then just type until done and hit ctrl-d. And I'd use less to view it because, well, less is more.

Not sure I followed the last bit, but you can launch an X app as root from an xterm.

-- Duh - you can *create* a file with cat. To edit it, you'd have to use ed or sed. *g*

Last edited by slakmagik; 10-29-2003 at 11:24 AM.
 
Old 10-29-2003, 11:35 AM   #8
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
One small other nitpick:

cat > file => creates the file or overwrites, so you always start with a empty file.

cat >> file => append to file or create if it doesn't excists.

 
  


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
Xlib errors when trying to open graphical app from command line, 9.1 Personal Baddox Suse/Novell 4 09-21-2005 11:31 PM
nfs a file shares ok via file mngr but not command line. Suse 9.1 acummings Linux - Networking 2 10-09-2004 02:23 PM
Command to output file content line by line aznluvsmc Programming 2 09-12-2004 07:45 PM
Howdo I open a file in Gimp 2 from the command line? shea1roh Linux - Software 4 07-12-2004 08:43 PM
macos-like command line file viewer (open) in linux shunker Linux - Newbie 0 12-25-2003 07:21 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration