Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 08-09-2005, 05:32 AM   #1
Registered: Sep 2004
Location: NorCal
Distribution: slackware 10.1 comfy, Solaris10 learning
Posts: 232

Rep: Reputation: 32
posting code from command line

A really stupid question: what is the easiest way to post code from command line onto this forums, without using mouse to cut and paste. And possibly using vim to write the posts.

Last edited by frankie_DJ; 08-09-2005 at 06:28 AM.
Old 08-09-2005, 05:51 AM   #2
Senior Member
Registered: Sep 2003
Location: Egypt
Distribution: Arch
Posts: 1,528

Rep: Reputation: 47
if its an error msg then type :

thecommand 2> output.txt

this will put the error message in output.txt
Old 08-09-2005, 06:26 AM   #3
Registered: Sep 2004
Location: NorCal
Distribution: slackware 10.1 comfy, Solaris10 learning
Posts: 232

Original Poster
Rep: Reputation: 32

I don't mean to be rude but:arere you sure you posted in the right thread? I am looking for a way to interact with this website better, write my posts in vi, write code from command line to the post easily , without copy and paste. Maybe I can do that with some browser feature. Or maybe the best would be subscribing to a thread and use command line email clients like pine or something. Any thoughts?
Old 08-09-2005, 08:51 AM   #4
Registered: Feb 2005
Location: Ontario, Canada
Distribution: Gentoo, Slackware
Posts: 345

Rep: Reputation: 30
If you're editing a file called post.txt with vi/vim ,and you want to insert the output of some command into your file, then I would do it this way.

Save your file in vim (using :w )
Then drop to a command line (using :! sh)
Run your command, and append all output back onto your file.
eg. "yourcommand >> post.txt 2>> post.txt"
This will append the output of the command onto the end of your file.
Then type exit and you'll return to vim and the output of the command will magically be at the end of your file

Make sure you use the double chevrons >> as opposed to > or your post will be completely over written by the output, rather than having the output appended to the end.


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
Command to output file content line by line aznluvsmc Programming 2 09-12-2004 07:45 PM
51 characters only in the 1st Line of command line eggCover Linux - General 2 07-29-2004 01:28 PM
C program code to run a Linux command line Linh Programming 10 06-11-2003 01:59 PM
Add lines of code to files from command line robeb Linux - General 2 06-12-2002 03:54 AM
suggestions for subject line when posting. abrakadabra LQ Suggestions & Feedback 14 05-16-2002 09:03 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:31 AM.

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